fix: prevent partial file reads during concurrent downloads#1548
Open
nico-martin wants to merge 4 commits intomainfrom
Open
fix: prevent partial file reads during concurrent downloads#1548nico-martin wants to merge 4 commits intomainfrom
nico-martin wants to merge 4 commits intomainfrom
Conversation
5 tasks
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Collaborator
|
@sroussey would be great to get your take on this PR! :) |
Contributor
|
Looks good to me! |
Contributor
|
btw... does unlink() work for directories? |
Contributor
|
from the node docs: To get a behavior similar to the rm -rf Unix command, use fsPromises.rm() with options { recursive: true, force: true }. https://nodejs.org/api/fs.html#fspromisesrmpath-options This is in regards to the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1544
What
Writes model files to a unique
.tmp.<pid>.<random>path first, then atomically renames to the final path once the download is complete. This ensures concurrent readers (whether in other processes or in the same process) never see a partially-written file.Changes
hub/files.js→ split intohub/FileResponse.jsandcache/FileCache.jsFileCache.put()now writes to a unique temp file and renames atomically on success, or deletes on errorThe main fix is this commit and this small improvement. The rest ist just some clean-up.