Skip to content

Commit 99e991f

Browse files
committed
bucket notifications - wrong etag, size (#8819)
Signed-off-by: Amit Prinz Setter <[email protected]>
1 parent c219c61 commit 99e991f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/endpoint/s3/ops/s3_put_object.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ async function put_object(req, res) {
6565
}
6666
s3_utils.set_encryption_response_headers(req, res, reply.encryption);
6767

68+
res.size_for_notif = size || reply.size;
69+
6870
if (copy_source) {
6971
// TODO: This needs to be checked regarding copy between diff namespaces
7072
// In that case we do not have the copy_source property and just read and upload the stream

src/sdk/namespace_fs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,8 @@ class NamespaceFS {
24502450
return {
24512451
etag,
24522452
encryption,
2453-
version_id
2453+
version_id,
2454+
size: stat.size
24542455
};
24552456
}
24562457

src/util/notifications_util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ function compose_notification_req(req, res, bucket, notif_conf) {
422422
let eTag = res.getHeader('ETag');
423423
//eslint-disable-next-line
424424
if (eTag && eTag.startsWith('\"') && eTag.endsWith('\"')) {
425-
eTag = eTag.substring(2, eTag.length - 2);
425+
eTag = eTag.substring(1, eTag.length - 1);
426426
}
427427

428428
const event = OP_TO_EVENT[req.op_name];
@@ -442,7 +442,7 @@ function compose_notification_req(req, res, bucket, notif_conf) {
442442
"x-amz-id-2": req.request_id,
443443
};
444444
notif.s3.object.key = req.params.key;
445-
notif.s3.object.size = res.getHeader('content-length');
445+
notif.s3.object.size = res.size_for_notif;
446446
notif.s3.object.eTag = eTag;
447447
notif.s3.object.versionId = res.getHeader('x-amz-version-id');
448448

@@ -462,6 +462,8 @@ function compose_notification_req(req, res, bucket, notif_conf) {
462462
notif.s3.object.sequencer = res.seq;
463463
}
464464

465+
delete res.size_for_notif;
466+
465467
return compose_meta(notif, notif_conf, bucket);
466468
}
467469

0 commit comments

Comments
 (0)