Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Recreate store directory if not there for existing source #5944

Merged

Conversation

prateekj117
Copy link
Contributor

Status

Ready for review

Description of Changes

If an admin accidentally or intentionally wipes out the store directory of a particular source (i.e., the store/{filesystem_id}), the source gets a FileNotFoundError when trying to submitting the documents again.

Fixes #5787

Changes proposed in this pull request:
A simple check which creates the store/{filesystem_id} dir for a source if it not already exists.

Testing

How should the reviewer test this PR?
Mentioned in the description of issue #5787

Checklist

If you made changes to the server application code:

  • Linting (make lint) and tests (make test) pass in the development container

@prateekj117 prateekj117 requested a review from a team as a code owner May 15, 2021 14:02
@prateekj117 prateekj117 force-pushed the recreate-store-directory branch from bc5d4b1 to 1a096ce Compare May 15, 2021 14:17
@prateekj117 prateekj117 changed the title Recreate store directory fix: Recreate store directory is not there for existing source May 15, 2021
@prateekj117 prateekj117 changed the title fix: Recreate store directory is not there for existing source fix: Recreate store directory if not there for existing source May 15, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2021

Codecov Report

Merging #5944 (1a096ce) into develop (6eb5ac8) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5944      +/-   ##
===========================================
- Coverage    85.37%   85.30%   -0.07%     
===========================================
  Files           53       53              
  Lines         3876     3879       +3     
  Branches       480      481       +1     
===========================================
  Hits          3309     3309              
- Misses         455      457       +2     
- Partials       112      113       +1     
Impacted Files Coverage Δ
securedrop/source_app/main.py 91.00% <0.00%> (-1.47%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6eb5ac8...1a096ce. Read the comment docs.

@prateekj117
Copy link
Contributor Author

@eloquence @rmol Let me know if tests are required.

Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prateekj117 Thanks for tackling. Tested the changes locally, and the behavior works as intended: a manually removed directory will be recreated, no error is shown, and subsequent submissions succeed. Just what we wanted.

In the future, please do try to include tests to validate the behavior you're introducing!

@conorsch conorsch merged commit 41e79e7 into freedomofpress:develop May 18, 2021
@zenmonkeykstop zenmonkeykstop mentioned this pull request Jun 14, 2021
39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants