Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/core/bucketEntries/BucketEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface BucketEntry {
renewal?: Date;
version?: number;
size?: number;
hmac?: { type: 'sha512'; value: string };
}

export interface BucketEntryWithFrame extends Omit<BucketEntry, 'frame'> {
Expand Down
10 changes: 6 additions & 4 deletions lib/core/buckets/usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,12 @@ export class BucketsUsecase {
}

async completeUpload(
userId: User['uuid'],
bucketId: Bucket['id'],
fileIndex: string,
userId: User['uuid'],
bucketId: Bucket['id'],
fileIndex: string,
shards: ShardWithPossibleMultiUpload[],
auth: { username: string; password: string }
auth: { username: string; password: string },
hmac?: { type: 'sha512'; value: string }
): Promise<BucketEntry> {
const [bucket, user, uploads] = await Promise.all([
this.bucketsRepository.findOne({ id: bucketId }),
Expand Down Expand Up @@ -576,6 +577,7 @@ export class BucketsUsecase {
index: fileIndex,
version: 2,
size: bucketEntrySize,
hmac,
});

const [newBucketEntry, ...newShards] = await Promise.all([
Expand Down
8 changes: 5 additions & 3 deletions lib/server/routes/buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ BucketsRouter.prototype.finishUpload = async function (req, res, next) {
return next(new errors.BadRequestError('Missing parameters'));
}

const { index, shards } = req.body;
const { index, shards, hmac } = req.body;

if (!isHexString(index) || index.length !== 64) {
return next(new errors.BadRequestError('Invalid index'));
Expand Down Expand Up @@ -1302,7 +1302,8 @@ BucketsRouter.prototype.finishUpload = async function (req, res, next) {
bucketId,
index,
shards,
auth
auth,
hmac
);

await this.fileStateUsecase.updateOrSetLastAccessDate(bucketEntry.id)
Expand Down Expand Up @@ -1407,7 +1408,8 @@ BucketsRouter.prototype.getDownloadLinks = async function (req, res, next) {
bucket: bucketId,
index: bucketEntry.index,
created: bucketEntry.created,
shards: shardsWithoutUuid
shards: shardsWithoutUuid,
hmac: bucketEntry.hmac,
});
};

Expand Down
Loading