Skip to content

Commit

Permalink
feat(append): add support for beforeComplete
Browse files Browse the repository at this point in the history
  • Loading branch information
olalonde committed Sep 27, 2016
1 parent 7cc5a80 commit f5a4173
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fs-tus-store",
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"main": "./lib/index.js",
"directories": {
Expand Down Expand Up @@ -64,7 +64,7 @@
}
},
"dependencies": {
"abstract-tus-store": "^1.4.0",
"abstract-tus-store": "^1.5.0",
"common-streams": "^1.2.0",
"concat-stream": "^1.5.2",
"debug": "^2.2.0",
Expand All @@ -74,4 +74,4 @@
"string-to-stream": "^1.1.0",
"uuid": "^2.0.3"
}
}
}
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ export default ({
return meterStream
}

const completeUpload = async (uploadId, upload) => {
const completeUpload = async (uploadId, upload, beforeComplete) => {
await beforeComplete(upload, uploadId)
const oldPath = keyToPath(uploadIdToDataKey(uploadId))
const newPath = keyToPath(upload.key)
const uploadResourcePath = keyToPath(uploadIdToKey(uploadId))
Expand All @@ -175,6 +176,7 @@ export default ({
}
return { expectedOffset: arg3, opts: arg4 }
})()
const { beforeComplete = async () => {} } = opts
// need to do this asap to make sure we don't miss reads
const through = rs.pipe(new PassThrough())

Expand Down Expand Up @@ -203,7 +205,7 @@ export default ({
})
const newOffset = offset + bytesWritten
if (newOffset === upload.uploadLength) {
await completeUpload(uploadId, upload)
await completeUpload(uploadId, upload, beforeComplete)
return {
offset: newOffset,
complete: true,
Expand Down

0 comments on commit f5a4173

Please sign in to comment.