diff --git a/src/calibre/ebooks/metadata/meta.py b/src/calibre/ebooks/metadata/meta.py index 77005c0f89..46ee801fd6 100644 --- a/src/calibre/ebooks/metadata/meta.py +++ b/src/calibre/ebooks/metadata/meta.py @@ -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) diff --git a/src/calibre/gui2/auto_add.py b/src/calibre/gui2/auto_add.py index c11dea88d0..fbaf3a10ff 100644 --- a/src/calibre/gui2/auto_add.py +++ b/src/calibre/gui2/auto_add.py @@ -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