mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Use URL safe characters for library ids
This commit is contained in:
parent
c29015a3ad
commit
818d5a9070
@ -11,7 +11,6 @@ from collections import OrderedDict
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from calibre import force_unicode
|
|
||||||
from calibre.db.cache import Cache
|
from calibre.db.cache import Cache
|
||||||
from calibre.db.legacy import create_backend, LibraryDatabase
|
from calibre.db.legacy import create_backend, LibraryDatabase
|
||||||
from calibre.srv.routes import Router
|
from calibre.srv.routes import Router
|
||||||
@ -27,15 +26,15 @@ class LibraryBroker(object):
|
|||||||
def __init__(self, libraries):
|
def __init__(self, libraries):
|
||||||
self.lock = Lock()
|
self.lock = Lock()
|
||||||
self.lmap = {}
|
self.lmap = {}
|
||||||
for path in libraries:
|
seen = set()
|
||||||
|
for i, path in enumerate(os.path.abspath(p) for p in libraries):
|
||||||
|
if path in seen:
|
||||||
|
continue
|
||||||
|
seen.add(path)
|
||||||
if not LibraryDatabase.exists_at(path):
|
if not LibraryDatabase.exists_at(path):
|
||||||
continue
|
continue
|
||||||
library_id = base = force_unicode(os.path.basename(path))
|
library_id = 'lib%d' % len(self.lmap)
|
||||||
c = 0
|
if i == 0:
|
||||||
while library_id in self.lmap:
|
|
||||||
c += 1
|
|
||||||
library_id = base + ' (1)'
|
|
||||||
if path is libraries[0]:
|
|
||||||
self.default_library = library_id
|
self.default_library = library_id
|
||||||
self.lmap[library_id] = path
|
self.lmap[library_id] = path
|
||||||
self.category_caches = {lid:OrderedDict() for lid in self.lmap}
|
self.category_caches = {lid:OrderedDict() for lid in self.lmap}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user