Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

issue with file uploads when its running concurrently #2

Merged
merged 2 commits into from

3 participants

@amdstorm

i was testing out concurrent file upload of 3-10 files, and mpu file upload temporary file generation causes an issue during concurrency.

apparently date.now() generates the same number for some temporary files, causing the file to be deleted.

@seangarner

thanks @amdstorm I was just about to clone to fix this myself when I spotted this pull request

@nathanoehlman nathanoehlman merged commit a7c1cae into from
@nathanoehlman

Thanks @amdstorm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2013
  1. @amdstorm
  2. @amdstorm

    added random seed

    amdstorm authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/multipartupload.js
View
8 lib/multipartupload.js
@@ -115,7 +115,7 @@ MultiPartUpload.prototype._handleStream = function(stream, callback) {
// Create a new part
function newPart() {
var partId = parts.length + 1,
- partFileName = path.resolve(path.join(os.tmpDir(), 'mpu-' + (mpu.uploadId || Date.now()) + '-' + partId)),
+ partFileName = path.resolve(path.join(os.tmpDir(), 'mpu-' + this.objectName + '-' + random_seed() + '-' + (mpu.uploadId || Date.now()) + '-' + partId)),
partFile = fs.createWriteStream(partFileName),
part = {
id: partId,
@@ -249,4 +249,8 @@ MultiPartUpload.prototype._completeUploads = function(callback) {
});
}
-module.exports = MultiPartUpload;
+module.exports = MultiPartUpload;
+
+function random_seed(){
+ return 'xxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);});
+}
Something went wrong with that request. Please try again.