Skip to content

Commit 31c8723

Browse files
authored
Merge pull request #260 from willnewii/patch-1
Update resume.js
2 parents 5d40aad + bd056a7 commit 31c8723

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

qiniu/storage/resume.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ function putReq(config, uploadToken, key, rsStream, rsStreamLen, putExtra,
143143
} catch (e) {}
144144
}
145145

146+
var isEnd = rsStream._readableState.ended;
147+
146148
//check when to mkblk
147149
rsStream.on('data', function(chunk) {
148150
readLen += chunk.length;
@@ -179,6 +181,9 @@ function putReq(config, uploadToken, key, rsStream, rsStreamLen, putExtra,
179181
}
180182

181183
rsStream.resume();
184+
if (isEnd) {
185+
mkfileReq(upDomain, uploadToken, fileSize, finishedCtxList, key, putExtra, callbackFunc);
186+
}
182187
}
183188
});
184189
}
@@ -188,8 +193,10 @@ function putReq(config, uploadToken, key, rsStream, rsStreamLen, putExtra,
188193
//check when to mkfile
189194
rsStream.on('end', function() {
190195
//console.log("end");
191-
mkfileReq(upDomain, uploadToken, fileSize, finishedCtxList, key,
196+
if (!isEnd) {
197+
mkfileReq(upDomain, uploadToken, fileSize, finishedCtxList, key,
192198
putExtra, callbackFunc);
199+
}
193200
});
194201
}
195202

0 commit comments

Comments
 (0)