Store new path only after successful write

This commit is contained in:
Will Burden 2025-12-13 00:14:14 +00:00
parent 2d0c48757e
commit d460139b45

View file

@ -125,9 +125,8 @@ class ReplacePlugin(BeetsPlugin):
except Exception as e:
raise ui.UserError(f"Could not delete original file: {e}")
# Store the new path in the database.
# Update the path to point to the new file.
song.path = str(dest).encode()
song.store()
# Write the metadata in the database to the song file's tags.
try:
@ -135,4 +134,7 @@ class ReplacePlugin(BeetsPlugin):
except Exception as e:
raise ui.UserError(f"Error writing metadata to file: {e}")
# Commit the new path to the database.
song.store()
ui.print_("Replacement successful.")