Skip to content

Commit

Permalink
fix: move block on try/catch (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos authored Jun 14, 2023
1 parent 8f29530 commit 14925de
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/http/routes/tus/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ export class Patch extends PatchHandler {
const uploadID = UploadId.fromString(id)

const uploader = new Uploader(req.upload.storage.backend, req.upload.storage.db)
await uploader.canUpload({
bucketId: uploadID.bucket,
objectName: uploadID.objectName,
isUpsert: req.headers['x-upsert'] === 'true',
})

try {
await uploader.canUpload({
bucketId: uploadID.bucket,
objectName: uploadID.objectName,
isUpsert: req.headers['x-upsert'] === 'true',
})

return await lock(uploadID, req.upload.storage, (db) => {
req.upload.storage = new Storage(req.upload.storage.backend, db)
return super.send(req, res)
Expand Down Expand Up @@ -76,13 +77,14 @@ export class Head extends HeadHandler {
const uploadID = UploadId.fromString(id)

const uploader = new Uploader(req.upload.storage.backend, req.upload.storage.db)
await uploader.canUpload({
bucketId: uploadID.bucket,
objectName: uploadID.objectName,
isUpsert: req.headers['x-upsert'] === 'true',
})

try {
await uploader.canUpload({
bucketId: uploadID.bucket,
objectName: uploadID.objectName,
isUpsert: req.headers['x-upsert'] === 'true',
})

return await lock(
uploadID,
req.upload.storage,
Expand Down

0 comments on commit 14925de

Please sign in to comment.