mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
8293226c5f
commit
3a0311d973
@ -424,9 +424,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
error_dialog(self, _('Bad database location'),
|
error_dialog(self, _('Bad database location'),
|
||||||
_('Bad database location')+':'+self.library_path,
|
_('Bad database location')+':'+self.library_path,
|
||||||
det_msg=traceback.format_exc()).exec_()
|
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,
|
dir = unicode(QFileDialog.getExistingDirectory(self,
|
||||||
_('Choose a location for your ebook library.'),
|
_('Choose a location for your ebook library.'),
|
||||||
os.path.expanduser('~')))
|
x))
|
||||||
if not dir:
|
if not dir:
|
||||||
QCoreApplication.exit(1)
|
QCoreApplication.exit(1)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
@ -1447,7 +1447,18 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
def move_library_to(self, newloc, progress=lambda x: x):
|
def move_library_to(self, newloc, progress=lambda x: x):
|
||||||
if not os.path.exists(newloc):
|
if not os.path.exists(newloc):
|
||||||
os.makedirs(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([])
|
old_dirs = set([])
|
||||||
for i, x in enumerate(items):
|
for i, x in enumerate(items):
|
||||||
src = os.path.join(self.library_path, x)
|
src = os.path.join(self.library_path, x)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user