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.
Description
Fixes #238
What changed?
securedrop_client/message_sync.py
securedrop_client/storage.py
rename_file
functionupdate_submissions
andupdate_replies
now update data files to match new filenames in the db.tests/conftest.py- I added aI plan to make a follow-up PR for a couple renaming refactors that would have made this PR harder to follow had I added them here. But basically I think we need to passdata_dir
pytest function.data_dir
where we passhomedir
in many test instances. Not a huge deal but it would be more correct to mimic what we do in production.tests/test_storage.py
rename_file
functiontest_update_submissions
andtest_update_replies
to check thatrename_file
is called if the local storage filenames need to be updatedUpdate:
The reply and submission files are renamed in these functions when we have both the local filename and server filename. This makes it easy to ensure local matches what's on the server.
Another option would be to rename the files in
update_sources
when thejournalist_designation
has changed. This would show the connection between a newjournalist_designation
and filename updates, but the code would be a bit more complicated because the filenames would need to be rebuilt, hard-coding the file naming structure so that we can find and replace thejournalist_designation
in the middle of the filename.I went with the first option because it would require less maintenance if in the future we decide to change the way files are named or there ends up being more reasons that file names can become out of sync. This logic says "regardless of reason the names have changed, local should always match the server."