mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove entry from list of known libraries when quick switching, if no library found
This commit is contained in:
parent
2884c0ca78
commit
9805054fa1
@ -13,7 +13,7 @@ from PyQt4.Qt import QMenu
|
|||||||
from calibre import isbytestring
|
from calibre import isbytestring
|
||||||
from calibre.constants import filesystem_encoding
|
from calibre.constants import filesystem_encoding
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs, warning_dialog
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
|
||||||
class LibraryUsageStats(object):
|
class LibraryUsageStats(object):
|
||||||
@ -34,6 +34,10 @@ class LibraryUsageStats(object):
|
|||||||
self.stats.pop(key)
|
self.stats.pop(key)
|
||||||
gprefs.set('library_usage_stats', self.stats)
|
gprefs.set('library_usage_stats', self.stats)
|
||||||
|
|
||||||
|
def remove(self, location):
|
||||||
|
self.stats.pop(location, None)
|
||||||
|
self.write_stats()
|
||||||
|
|
||||||
def canonicalize_path(self, lpath):
|
def canonicalize_path(self, lpath):
|
||||||
if isbytestring(lpath):
|
if isbytestring(lpath):
|
||||||
lpath = lpath.decode(filesystem_encoding)
|
lpath = lpath.decode(filesystem_encoding)
|
||||||
@ -123,6 +127,16 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
|
|
||||||
def switch_requested(self, location):
|
def switch_requested(self, location):
|
||||||
loc = location.replace('/', os.sep)
|
loc = location.replace('/', os.sep)
|
||||||
|
exists = self.gui.library_view.model().db.exists_at(loc)
|
||||||
|
if not exists:
|
||||||
|
warning_dialog(self.gui, _('No library found'),
|
||||||
|
_('No existing calibre library was found at %s.'
|
||||||
|
' It will be removed from the list of known '
|
||||||
|
' libraries.')%loc, show=True)
|
||||||
|
self.stats.remove(location)
|
||||||
|
self.build_menus()
|
||||||
|
return
|
||||||
|
|
||||||
prefs['library_path'] = loc
|
prefs['library_path'] = loc
|
||||||
self.gui.library_moved(loc)
|
self.gui.library_moved(loc)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user