Skip to content

save_file should store the file etag hash so that it doesn't need to be calculated on each read #181

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

Closed
ShaneHarvey opened this issue Jan 15, 2025 · 1 comment · Fixed by #182

Comments

@ShaneHarvey
Copy link
Collaborator

In #170 we remove md5 hashing and updated send_file to dynamically calculate the sha1 hash on each call. This is expensive because it requires reading the full GridFS file and hashing the contents to set the etag, then we read the file in full again to send the file itself.

It would be better for save_file to add the etag hash to the GridFS file metadata so that it doesn't need to be recalculated on each send_file call.

@ShaneHarvey
Copy link
Collaborator Author

ShaneHarvey commented Jan 15, 2025

We should also check if send_file() can be used on preexisting GridFS files, ie files not uploaded via save_file(). In that case we may need to keep the current lazy sha1 calculation as a backup when the hash metadata field is missing.

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 a pull request may close this issue.

1 participant