From 559ecdaf249de9f6fa4f0bd40701542c07d8d235 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 13:11:40 -0700 Subject: [PATCH] ... --- src/calibre/library/database2.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 9f6712f22a..521f688251 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -125,15 +125,17 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): self.dbpath = os.path.join(library_path, 'metadata.db') self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', 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): - 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() shutil.copyfile(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) self.connect()