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: django-storage 1.14 complains about files being opened twice when copying #1418

Merged
merged 14 commits into from
Sep 8, 2023

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Sep 6, 2023

Description

While the root cause of the bug #1417 might be in django-storages 1.14, this quick-fix ensures that any ValueError raised opening a file for copying does not crash the file application with a server error.

Related resources

Checklist

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

@fsbraun fsbraun requested a review from a team September 6, 2023 10:04
filer/models/filemodels.py Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Sep 6, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (ac3985d) 75.21% compared to head (a4cfe26) 75.22%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1418   +/-   ##
=======================================
  Coverage   75.21%   75.22%           
=======================================
  Files          75       75           
  Lines        3454     3455    +1     
  Branches      555      555           
=======================================
+ Hits         2598     2599    +1     
  Misses        691      691           
  Partials      165      165           
Files Changed Coverage Δ
filer/admin/folderadmin.py 75.65% <100.00%> (ø)
filer/models/filemodels.py 88.69% <100.00%> (+0.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fsbraun fsbraun requested a review from vinitkumar September 7, 2023 06:05
@vinitkumar
Copy link
Member

@fsbraun Is it possible to have a test with this patch?

@fsbraun
Copy link
Member Author

fsbraun commented Sep 8, 2023

@vinitkumar I know! I've been thinking about it, but I do not see a way of testing this without the specific implementation of django-storage's S3Storage on an AWS instance. I frankly believe that the underlying issue is between Django and django-storage, but it's hard to tell. Since thetry except block.

Any idea how to test this?

@vinitkumar
Copy link
Member

@fsbraun I don't know. Seems hard to implement in the test. Have you tried testing this patch with a real s3 backend?

@fsbraun
Copy link
Member Author

fsbraun commented Sep 8, 2023

@vinitkumar I tested it on my staging setup with AWS: Without the fix, copying files fails and a copy of the first file remains in the source folder. After fixing it, copying works fine.

The fix also does not affect local file storage (which just runs seek(0) in case of a reopen).

Copy link
Member

@vinitkumar vinitkumar left a comment

Choose a reason for hiding this comment

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

Looks good to me. Let's get this merged and released 🚢 🚀

@vinitkumar vinitkumar merged commit 68f6aaa into django-cms:master Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants