move directory pruning later in import process

Fixes a thing where pruning would remove the album art before fetchart could
get it.
This commit is contained in:
Adrian Sampson 2013-09-29 18:29:49 -07:00
parent bb21ec692e
commit bd0580680f
2 changed files with 15 additions and 4 deletions

View file

@ -839,13 +839,13 @@ def manipulate_files(session):
# Move/copy/write files.
items = task.imported_items()
task.old_paths = [item.path for item in items] # For deletion.
# Save the original paths of all items for deletion and pruning
# in the next step (finalization).
task.old_paths = [item.path for item in items]
for item in items:
if config['import']['move']:
# Just move the file.
old_path = item.path
item.move(False)
task.prune(old_path)
elif config['import']['copy']:
# If it's a reimport, move in-library files and copy
# out-of-library files. Otherwise, copy and keep track
@ -903,7 +903,7 @@ def finalize(session):
plugins.send('item_imported',
lib=session.lib, item=item)
# Finally, delete old files.
# When copying and deleting originals, delete old files.
if config['import']['copy'] and config['import']['delete']:
new_paths = [os.path.realpath(item.path) for item in items]
for old_path in task.old_paths:
@ -912,6 +912,12 @@ def finalize(session):
util.remove(syspath(old_path), False)
task.prune(old_path)
# When moving, prune empty directories containing the original
# files.
elif config['import']['move']:
for old_path in task.old_paths:
task.prune(old_path)
# Update progress.
if _resume():
task.save_progress()

View file

@ -39,6 +39,11 @@ And some fixes:
Klähn.
* :doc:`/plugins/lastgenre`: Fix a regression that could cause new genres
found during import not to be persisted.
* Fixed a crash when imported album art was also marked as "clutter" where the
art would be deleted before it could be moved into place. This led to a
"image.jpg not found during copy" error. Now clutter is removed (and
directories pruned) much later in the process, after the
``import_task_files`` hook.
.. _Opus: http://www.opus-codec.org/
.. _@Verrus: https://github.com/Verrus