Avoid creating metadata.opf files in the root of the library when adding books

This commit is contained in:
Charles Haley 2010-10-23 15:11:06 +01:00
parent fddf3abf92
commit 3839b99e9c

View File

@ -654,16 +654,20 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
def get_metadata_for_dump(self, idx, remove_from_dirtied=True): def get_metadata_for_dump(self, idx, remove_from_dirtied=True):
try: try:
path = os.path.join(self.abspath(idx, index_is_id=True), 'metadata.opf') path, mi = (None, None)
mi = self.get_metadata(idx, index_is_id=True) # While a book is being created, the path is empty. Don't bother to
# Always set cover to cover.jpg. Even if cover doesn't exist, # try to write the opf, because it will go to the wrong folder.
# no harm done. This way no need to call dirtied when if self.path(idx, index_is_id=True):
# cover is set/removed path = os.path.join(self.abspath(idx, index_is_id=True), 'metadata.opf')
mi.cover = 'cover.jpg' mi = self.get_metadata(idx, index_is_id=True)
# Always set cover to cover.jpg. Even if cover doesn't exist,
# no harm done. This way no need to call dirtied when
# cover is set/removed
mi.cover = 'cover.jpg'
except: except:
# This almost certainly means that the book has been deleted while # This almost certainly means that the book has been deleted while
# the backup operation sat in the queue. # the backup operation sat in the queue.
path, mi = (None, None) pass
try: try:
# clear the dirtied indicator. The user must put it back if # clear the dirtied indicator. The user must put it back if