From bd0580680fdc993b36c9e97b9bd40321dada56c1 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 29 Sep 2013 18:29:49 -0700 Subject: [PATCH] move directory pruning later in import process Fixes a thing where pruning would remove the album art before fetchart could get it. --- beets/importer.py | 14 ++++++++++---- docs/changelog.rst | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/beets/importer.py b/beets/importer.py index d24956a38..11823304e 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -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() diff --git a/docs/changelog.rst b/docs/changelog.rst index 8bad0e902..27b925ebd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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