mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 12:02:44 +01:00
fix import deletion race
By moving the duplicate file removal to the manipulate_files coroutine, we ensure that all previous albums are fully moved/copied before trying to delete their duplicate files.
This commit is contained in:
parent
e91a08099d
commit
ca206053ac
2 changed files with 18 additions and 5 deletions
|
|
@ -768,13 +768,12 @@ def apply_choices(session):
|
|||
|
||||
# Delete duplicate files that are located inside the library
|
||||
# directory.
|
||||
task.duplicate_paths = []
|
||||
for duplicate_path in [i.path for i in duplicate_items]:
|
||||
if session.lib.directory in util.ancestry(duplicate_path):
|
||||
log.debug(u'deleting replaced duplicate %s' %
|
||||
util.displayable_path(duplicate_path))
|
||||
util.remove(duplicate_path)
|
||||
util.prune_dirs(os.path.dirname(duplicate_path),
|
||||
session.lib.directory)
|
||||
# Mark the path for deletion in the manipulate_files
|
||||
# stage.
|
||||
task.duplicate_paths.append(duplicate_path)
|
||||
|
||||
# Add items -- before path changes -- to the library. We add the
|
||||
# items now (rather than at the end) so that album structures
|
||||
|
|
@ -823,6 +822,15 @@ def manipulate_files(session):
|
|||
if task.should_skip():
|
||||
continue
|
||||
|
||||
# Remove duplicate files marked for deletion.
|
||||
if task.remove_duplicates:
|
||||
for duplicate_path in task.duplicate_paths:
|
||||
log.debug(u'deleting replaced duplicate %s' %
|
||||
util.displayable_path(duplicate_path))
|
||||
util.remove(duplicate_path)
|
||||
util.prune_dirs(os.path.dirname(duplicate_path),
|
||||
session.lib.directory)
|
||||
|
||||
# Move/copy/write files.
|
||||
items = task.imported_items()
|
||||
task.old_paths = [item.path for item in items] # For deletion.
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ Changelog
|
|||
* :doc:`/plugins/fetchart`: Look for images in the Cover Art Archive for
|
||||
the release group in addition to the specific release. Thanks to Filipe
|
||||
Fortes.
|
||||
* Fix a race in the importer that could cause files to be deleted before they
|
||||
were imported. This happened when importing one album, importing a duplicate
|
||||
album, and then asking for the first album to be replaced with the second.
|
||||
The situation could only arise when importing music from the library
|
||||
directory and when the two albums are imported close in time.
|
||||
|
||||
|
||||
1.2.1 (June 22, 2013)
|
||||
|
|
|
|||
Loading…
Reference in a new issue