mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-02 19:44:25 +02:00
Fix bugs in database migration logic
This commit is contained in:
parent
df8f2d88d0
commit
50c484fc35
1 changed files with 13 additions and 9 deletions
|
|
@ -688,16 +688,20 @@ def do_config(self):
|
|||
try:
|
||||
newloc = os.path.join(d.database_location, os.path.basename(self.database_path))
|
||||
if not os.path.exists(newloc):
|
||||
dirname = os.path.dirname(newloc)
|
||||
if not os.path.isdir(dirname):
|
||||
os.makedirs(dirname)
|
||||
dest = open(newloc, 'wb')
|
||||
self.status_bar.showMessage('Copying database to '+newloc)
|
||||
self.setCursor(Qt.BusyCursor)
|
||||
self.library_view.setEnabled(False)
|
||||
self.library_view.close()
|
||||
src = open(self.database_path, 'rb')
|
||||
shutil.copyfileobj(src, dest)
|
||||
src.close()
|
||||
dest.close()
|
||||
os.unlink(self.database_path)
|
||||
if os.access(self.database_path, os.R_OK):
|
||||
self.status_bar.showMessage('Copying database to '+newloc)
|
||||
self.setCursor(Qt.BusyCursor)
|
||||
self.library_view.setEnabled(False)
|
||||
self.library_view.close()
|
||||
src = open(self.database_path, 'rb')
|
||||
shutil.copyfileobj(src, dest)
|
||||
src.close()
|
||||
dest.close()
|
||||
os.unlink(self.database_path)
|
||||
else:
|
||||
try:
|
||||
db = LibraryDatabase(newloc)
|
||||
|
|
|
|||
Loading…
Reference in a new issue