mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Avoid creating metadata.opf files in the root of the library when adding books
This commit is contained in:
parent
fddf3abf92
commit
3839b99e9c
@ -654,16 +654,20 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
|
||||
def get_metadata_for_dump(self, idx, remove_from_dirtied=True):
|
||||
try:
|
||||
path = os.path.join(self.abspath(idx, index_is_id=True), 'metadata.opf')
|
||||
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'
|
||||
path, mi = (None, None)
|
||||
# While a book is being created, the path is empty. Don't bother to
|
||||
# try to write the opf, because it will go to the wrong folder.
|
||||
if self.path(idx, index_is_id=True):
|
||||
path = os.path.join(self.abspath(idx, index_is_id=True), 'metadata.opf')
|
||||
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:
|
||||
# This almost certainly means that the book has been deleted while
|
||||
# the backup operation sat in the queue.
|
||||
path, mi = (None, None)
|
||||
pass
|
||||
|
||||
try:
|
||||
# clear the dirtied indicator. The user must put it back if
|
||||
|
Loading…
x
Reference in New Issue
Block a user