mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Welcome Wizard: Don't leave behind an empty 'Calibre Library' directory if the user chooses another location for her library
This commit is contained in:
parent
a41ee9f6f2
commit
854587d38b
@ -473,6 +473,7 @@ class LibraryPage(QWizardPage, LibraryUI):
|
|||||||
|
|
||||||
def initializePage(self):
|
def initializePage(self):
|
||||||
lp = prefs['library_path']
|
lp = prefs['library_path']
|
||||||
|
self.default_library_name = None
|
||||||
if not lp:
|
if not lp:
|
||||||
fname = _('Calibre Library')
|
fname = _('Calibre Library')
|
||||||
if isinstance(fname, unicode):
|
if isinstance(fname, unicode):
|
||||||
@ -481,6 +482,7 @@ class LibraryPage(QWizardPage, LibraryUI):
|
|||||||
except:
|
except:
|
||||||
fname = 'Calibre Library'
|
fname = 'Calibre Library'
|
||||||
lp = os.path.expanduser('~'+os.sep+fname)
|
lp = os.path.expanduser('~'+os.sep+fname)
|
||||||
|
self.default_library_name = lp
|
||||||
if not os.path.exists(lp):
|
if not os.path.exists(lp):
|
||||||
try:
|
try:
|
||||||
os.makedirs(lp)
|
os.makedirs(lp)
|
||||||
@ -497,6 +499,17 @@ class LibraryPage(QWizardPage, LibraryUI):
|
|||||||
def commit(self, completed):
|
def commit(self, completed):
|
||||||
oldloc = prefs['library_path']
|
oldloc = prefs['library_path']
|
||||||
newloc = unicode(self.location.text())
|
newloc = unicode(self.location.text())
|
||||||
|
try:
|
||||||
|
newloce = newloc.encode(filesystem_encoding)
|
||||||
|
if self.default_library_name is not None and \
|
||||||
|
os.path.exists(self.default_library_name) and \
|
||||||
|
not os.listdir(self.default_library_name) and \
|
||||||
|
newloce != self.default_library_name:
|
||||||
|
os.rmdir(self.default_library_name)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if not os.path.exists(newloc):
|
||||||
|
os.mkdir(newloc)
|
||||||
if not patheq(oldloc, newloc):
|
if not patheq(oldloc, newloc):
|
||||||
move_library(oldloc, newloc, self.wizard(), completed)
|
move_library(oldloc, newloc, self.wizard(), completed)
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user