mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
7c084b0630
commit
559ecdaf24
@ -125,15 +125,17 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
self.dbpath = os.path.join(library_path, 'metadata.db')
|
self.dbpath = os.path.join(library_path, 'metadata.db')
|
||||||
self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH',
|
self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH',
|
||||||
self.dbpath)
|
self.dbpath)
|
||||||
|
if isinstance(self.dbpath, unicode) and not iswindows:
|
||||||
|
self.dbpath = self.dbpath.encode(filesystem_encoding)
|
||||||
|
|
||||||
if read_only and os.path.exists(self.dbpath):
|
if read_only and os.path.exists(self.dbpath):
|
||||||
pt = PersistentTemporaryFile('_ro.db')
|
# Work on only a copy of metadata.db to ensure that
|
||||||
|
# metadata.db is not changed
|
||||||
|
pt = PersistentTemporaryFile('_metadata_ro.db')
|
||||||
pt.close()
|
pt.close()
|
||||||
shutil.copyfile(self.dbpath, pt.name)
|
shutil.copyfile(self.dbpath, pt.name)
|
||||||
self.dbpath = pt.name
|
self.dbpath = pt.name
|
||||||
|
|
||||||
if isinstance(self.dbpath, unicode) and not iswindows:
|
|
||||||
self.dbpath = self.dbpath.encode(filesystem_encoding)
|
|
||||||
|
|
||||||
apply_default_prefs = not os.path.exists(self.dbpath)
|
apply_default_prefs = not os.path.exists(self.dbpath)
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user