Skip to content

Commit ebae582

Browse files
author
Kerkesni
committed
fixup! support replacing account info in PutMetadata
1 parent 523015e commit ebae582

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

lib/routes/routeBackbeat.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,6 @@ function putData(request, response, bucketInfo, objMd, log, callback) {
482482
* @returns {undefined}
483483
*/
484484
function getCanonicalIdsByAccountId(accountId, log, cb) {
485-
if (!accountId) {
486-
return cb();
487-
}
488485
return vault.getCanonicalIdsByAccountIds([accountId], log, (err, res) => {
489486
if (err) {
490487
log.error('error getting canonical ID by account ID', {
@@ -638,19 +635,28 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
638635
}
639636

640637
return async.series([
641-
// Zenko's Backbeat delegates replacing the account
638+
// Zenko's CRR delegates replacing the account
642639
// information to the destination's Cloudserver, as
643640
// Vault admin APIs are not exposed externally.
644-
next => getCanonicalIdsByAccountId(request.query?.accountId, log, (err, res) => {
645-
if (err) {
646-
return next(err);
647-
}
648-
if (res) {
649-
omVal['owner-display-name'] = res.name;
650-
omVal['owner-id'] = res.canonicalId;
641+
next => {
642+
// Internal users of this API (other features in Zenko) will
643+
// not provide the accountId in the request, as they only update
644+
// the metadata of existing objects, so there is no need to
645+
// replace the account information.
646+
if (!request.query?.accountId) {
647+
return next();
651648
}
652-
return next();
653-
}),
649+
return getCanonicalIdsByAccountId(request.query.accountId, log, (err, res) => {
650+
if (err) {
651+
return next(err);
652+
}
653+
if (res) {
654+
omVal['owner-display-name'] = res.name;
655+
omVal['owner-id'] = res.canonicalId;
656+
}
657+
return next();
658+
});
659+
},
654660
next => {
655661
log.trace('putting object version', {
656662
objectKey: request.objectKey, omVal, options });

0 commit comments

Comments
 (0)