fix: Prevent duplicate attachment downloads (with tests) #448
+396
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes bug where attachments were downloaded multiple times with incremented filenames (file.mov, file_1.mov, file_2.mov) when running backups without --skip-existing flag.
I should not have used the --skip-existing flag for attachments, it did not do what I thought it did.
The correct approach is to always use the manifest to guide what has already been downloaded and what now needs to be done. The manifest is now checked on every run, regardless of flags.
In making this fix, I found it challenging not having tests to ensure there was no regression. So I also added pytest with a minimal setup and isolated configuration. Created a separate test workflow to keep tests isolated from linting. This will assist when others do a PR on the attachment code.
Tests cover the key elements of the attachment logic:
Broke the PR into two commits that handle the two activities separately.