Concurrent file uploads resulting in the same file version #59
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.
Hi all,
we spotted a issue with the way how the file version is calculated while a lot of clients (>10) uploading small files in parallel:
The
safeName()
method creates correctly a new file version name but does not touches the 'calculated' file name. Plus the 'begin' event is fired later on.This mean if a second
fileBegin
event is at the very same position and is executed (before the 'begin' of the first request is handled) the secondsafeName()
calculates the very same version.To avoid this, i added an
touch
for the created file.This solution is fine for one process working on a upload folder. But we have many node processes handling requests (behind an IIS via iisnode) therefore even that
touch
ing might not be possible as two processes reach that code in the very same moment (assuming a multicore system).Therefore an option
prefixUuid
has been created to allow the files to be created with a prefix. This new name is returned to the client as the versionized file name would be, too.