From 3a0311d973152d615658034a6596b7e251b611f5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 25 Aug 2009 10:50:28 -0600 Subject: [PATCH] On a new install choose an empty directory as library location by default. Also only transfer known sub-directories when moving the library. Fixes #3282 (Installing a new install of Calibre on a WinXP machine the library location is insane.) --- src/calibre/gui2/main.py | 5 ++++- src/calibre/library/database2.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 98ae6a3796..1f035d4bae 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -424,9 +424,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): error_dialog(self, _('Bad database location'), _('Bad database location')+':'+self.library_path, det_msg=traceback.format_exc()).exec_() + x = os.path.expanduser('~'+os.sep+'library') + if not os.path.exists(x): + os.makedirs(x) dir = unicode(QFileDialog.getExistingDirectory(self, _('Choose a location for your ebook library.'), - os.path.expanduser('~'))) + x)) if not dir: QCoreApplication.exit(1) raise SystemExit(1) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index c605be0879..c48b238c8d 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1447,7 +1447,18 @@ class LibraryDatabase2(LibraryDatabase): def move_library_to(self, newloc, progress=lambda x: x): if not os.path.exists(newloc): os.makedirs(newloc) - items = os.listdir(self.library_path) + items = set(os.listdir(self.library_path)) + paths = set([]) + for x in self.data.universal_set(): + path = self.path(x, index_is_id=True) + path = path.split(os.sep)[0] + paths.add(path) + paths.add('metadata.db') + if not self.is_case_sensitive: + items = set([x.lower() for x in items]) + paths = set([x.lower() for x in paths]) + items = items.intersection(paths) + old_dirs = set([]) for i, x in enumerate(items): src = os.path.join(self.library_path, x)