From 0ac0fe5bcd02cfc1923b02ad2de459a378d169a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Feb 2011 10:28:15 -0700 Subject: [PATCH] Fix regression that caused a spurious error message after moving a library. Also ensure that the entries in the Copy to Library menu are upadted after a library is moved/renamed/deleted. Fixes #8905 (After moving Library, the "Open in Containing Folder" option points to the old location) --- src/calibre/gui2/actions/choose_library.py | 16 +++++++++++++++- src/calibre/gui2/dialogs/choose_library.py | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/choose_library.py b/src/calibre/gui2/actions/choose_library.py index 7034380a56..f3a7f1742d 100644 --- a/src/calibre/gui2/actions/choose_library.py +++ b/src/calibre/gui2/actions/choose_library.py @@ -237,6 +237,7 @@ class ChooseLibraryAction(InterfaceAction): return self.stats.rename(location, newloc) self.build_menus() + self.gui.iactions['Copy To Library'].build_menus() def delete_requested(self, name, location): loc = location.replace('/', os.sep) @@ -253,6 +254,7 @@ class ChooseLibraryAction(InterfaceAction): pass self.stats.remove(location) self.build_menus() + self.gui.iactions['Copy To Library'].build_menus() def backup_status(self, location): dirty_text = 'no' @@ -329,6 +331,7 @@ class ChooseLibraryAction(InterfaceAction): ' libraries.')%loc, show=True) self.stats.remove(location) self.build_menus() + self.gui.iactions['Copy To Library'].build_menus() return prefs['library_path'] = loc @@ -371,9 +374,20 @@ class ChooseLibraryAction(InterfaceAction): if not self.change_library_allowed(): return from calibre.gui2.dialogs.choose_library import ChooseLibrary + self.gui.library_view.save_state() db = self.gui.library_view.model().db - c = ChooseLibrary(db, self.gui.library_moved, self.gui) + location = self.stats.canonicalize_path(db.library_path) + self.pre_choose_dialog_location = location + c = ChooseLibrary(db, self.choose_library_callback, self.gui) c.exec_() + self.choose_dialog_library_renamed = getattr(c, 'library_renamed', False) + + def choose_library_callback(self, newloc, copy_structure=False): + self.gui.library_moved(newloc, copy_structure=copy_structure) + if getattr(self, 'choose_dialog_library_renamed', False): + self.stats.rename(self.pre_choose_dialog_location, prefs['library_path']) + self.build_menus() + self.gui.iactions['Copy To Library'].build_menus() def change_library_allowed(self): if os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', None): diff --git a/src/calibre/gui2/dialogs/choose_library.py b/src/calibre/gui2/dialogs/choose_library.py index 033b038b65..24bd6591c6 100644 --- a/src/calibre/gui2/dialogs/choose_library.py +++ b/src/calibre/gui2/dialogs/choose_library.py @@ -71,6 +71,8 @@ class ChooseLibrary(QDialog, Ui_Dialog): prefs['library_path'] = loc self.callback(loc, copy_structure=self.copy_structure.isChecked()) else: + self.db.prefs.disable_setting = True + self.library_renamed = True move_library(self.db.library_path, loc, self.parent(), self.callback)