mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix non pruned databases being closed in library_moved()
This commit is contained in:
parent
c8737737ef
commit
7acc25fcbc
@ -685,9 +685,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
self.rebuild_vl_tabs()
|
self.rebuild_vl_tabs()
|
||||||
for action in self.iactions.values():
|
for action in self.iactions.values():
|
||||||
action.library_changed(db)
|
action.library_changed(db)
|
||||||
self.library_broker.gui_library_changed(db)
|
self.library_broker.gui_library_changed(db, olddb)
|
||||||
if olddb is not None:
|
|
||||||
olddb.close(), olddb.break_cycles()
|
|
||||||
if self.device_connected:
|
if self.device_connected:
|
||||||
self.set_books_in_library(self.booklists(), reset=True)
|
self.set_books_in_library(self.booklists(), reset=True)
|
||||||
self.refresh_ondevice()
|
self.refresh_ondevice()
|
||||||
|
@ -11,10 +11,17 @@ from threading import Lock
|
|||||||
from calibre import filesystem_encoding
|
from calibre import filesystem_encoding
|
||||||
from calibre.db.cache import Cache
|
from calibre.db.cache import Cache
|
||||||
from calibre.db.legacy import LibraryDatabase, create_backend, set_global_state
|
from calibre.db.legacy import LibraryDatabase, create_backend, set_global_state
|
||||||
from calibre.utils.filenames import samefile
|
from calibre.utils.filenames import samefile as _samefile
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
|
|
||||||
|
|
||||||
|
def samefile(a, b):
|
||||||
|
a, b = canonicalize_path(a), canonicalize_path(b)
|
||||||
|
if a == b:
|
||||||
|
return True
|
||||||
|
return _samefile(a, b)
|
||||||
|
|
||||||
|
|
||||||
def init_library(library_path, is_default_library):
|
def init_library(library_path, is_default_library):
|
||||||
db = Cache(
|
db = Cache(
|
||||||
create_backend(
|
create_backend(
|
||||||
@ -156,7 +163,7 @@ class GuiLibraryBroker(LibraryBroker):
|
|||||||
set_global_state(db)
|
set_global_state(db)
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def gui_library_changed(self, db, prune=True):
|
def gui_library_changed(self, db, olddb=None):
|
||||||
# Must be called with lock held
|
# Must be called with lock held
|
||||||
newloc = canonicalize_path(db.backend.library_path)
|
newloc = canonicalize_path(db.backend.library_path)
|
||||||
for library_id, path in self.lmap.iteritems():
|
for library_id, path in self.lmap.iteritems():
|
||||||
@ -169,8 +176,9 @@ class GuiLibraryBroker(LibraryBroker):
|
|||||||
self.lmap[library_id] = newloc
|
self.lmap[library_id] = newloc
|
||||||
self.loaded_dbs[library_id] = db
|
self.loaded_dbs[library_id] = db
|
||||||
db.new_api.server_library_id = library_id
|
db.new_api.server_library_id = library_id
|
||||||
if prune:
|
if olddb is not None and samefile(olddb.backend.library_path, db.backend.library_path):
|
||||||
self._prune_loaded_dbs()
|
olddb.close(), olddb.break_cycles()
|
||||||
|
self._prune_loaded_dbs()
|
||||||
|
|
||||||
def _prune_loaded_dbs(self):
|
def _prune_loaded_dbs(self):
|
||||||
now = monotonic()
|
now = monotonic()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user