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.)

This commit is contained in:
Kovid Goyal 2009-08-25 10:50:28 -06:00
parent 8293226c5f
commit 3a0311d973
2 changed files with 16 additions and 2 deletions

View File

@ -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)

View File

@ -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)