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

Create empty file if no bytes written to S3 file in 'w' mode #816

Merged
merged 5 commits into from
Feb 2, 2020

Conversation

chrisrink10
Copy link
Contributor

This PR adds functionality to S3Boto3StorageFile that will create an empty file if no bytes are written to S3 after opening a file in w mode, similar to how FileSystemStorage and Python's native open work.

Let me know if I'm missing anything or if you have any questions. Thank you!

Fixes #435

@chrisrink10
Copy link
Contributor Author

Looks like my remaining build failure is due to extra warnings being thrown on Python 3.8 for tests/test_s3boto3.py::S3Boto3Storagetests::test_deprecated_bucket. I'm not exactly clear how to proceed with fixing this issue. I don't think my changes caused this.

@jdufresne
Copy link
Contributor

Why should this be optional? Shouldn't the backend always follow the upstream behavior of FileSystemStorage?

@chrisrink10
Copy link
Contributor Author

@jdufresne Completely agree it should not be optional in an ideal world. I was concerned it would be a breaking change though, since that's not how it works right now. If people think it should be standard behavior I'm happy to make it that way (it's easier for me).

cc @jschneier

@blargoner
Copy link

@jschneier Any chance this can be merged? I love empty files.

@jschneier
Copy link
Owner

jschneier commented Jan 27, 2020 via email

@chrisrink10
Copy link
Contributor Author

@jschneier Thanks for the reply. I removed the setting.

Looks like the Python 3.8 build issue is resolved now.

@blargoner
Copy link

@jschneier Now that the setting is removed, any chance this can be merged? Thanks!

@jschneier jschneier merged commit 77fc5b0 into jschneier:master Feb 2, 2020
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.

S3Boto3StorageFile close() should mimic FileSystemStorage.close() for empty files
4 participants