mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Forgot to handle the case of import plugins creating a new file when auto-adding
This commit is contained in:
parent
ce1df69885
commit
92e5a55dbb
@ -230,10 +230,13 @@ def opf_metadata(opfpath):
|
||||
pass
|
||||
|
||||
|
||||
def forked_read_metadata(path, tdir):
|
||||
def forked_read_metadata(original_path, tdir):
|
||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||
from calibre.ebooks.metadata.worker import run_import_plugins
|
||||
path = run_import_plugins((path,), os.getpid(), tdir)[0]
|
||||
path = run_import_plugins((original_path,), os.getpid(), tdir)[0]
|
||||
if path != original_path:
|
||||
with lopen(os.path.join(tdir, 'file_changed_by_plugins'), 'w') as f:
|
||||
f.write(os.path.abspath(path))
|
||||
with lopen(path, 'rb') as f:
|
||||
fmt = os.path.splitext(path)[1][1:].lower()
|
||||
f.seek(0, 2)
|
||||
|
@ -229,7 +229,12 @@ class AutoAdder(QObject):
|
||||
added_ids = set()
|
||||
|
||||
for fname, tdir in data:
|
||||
paths = [os.path.join(self.worker.path, fname)]
|
||||
path_to_remove = os.path.join(self.worker.path, fname)
|
||||
paths = [path_to_remove]
|
||||
fpath = os.path.join(tdir, 'file_changed_by_plugins')
|
||||
if os.path.exists(fpath):
|
||||
with open(fpath) as f:
|
||||
paths[0] = f.read()
|
||||
sz = os.path.join(tdir, 'size.txt')
|
||||
try:
|
||||
with open(sz, 'rb') as f:
|
||||
@ -277,7 +282,7 @@ class AutoAdder(QObject):
|
||||
duplicates.append(dups)
|
||||
|
||||
try:
|
||||
os.remove(paths[0])
|
||||
os.remove(path_to_remove)
|
||||
self.worker.staging.remove(fname)
|
||||
except:
|
||||
import traceback
|
||||
|
Loading…
x
Reference in New Issue
Block a user