From e3cb0278cea027cf5dcb5b99d5efbd5b80a3be80 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 11 Oct 2022 14:36:06 -0700 Subject: [PATCH] honor specified target prefix under batch replication (#15834) --- cmd/batch-handlers.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/batch-handlers.go b/cmd/batch-handlers.go index 9ce973a25..ff7e730d1 100644 --- a/cmd/batch-handlers.go +++ b/cmd/batch-handlers.go @@ -268,6 +268,7 @@ func (r *BatchJobReplicateV1) ReplicateFromSource(ctx context.Context, api Objec func (r *BatchJobReplicateV1) ReplicateToTarget(ctx context.Context, api ObjectLayer, c *miniogo.Core, srcObjInfo ObjectInfo, retry bool) error { srcBucket := r.Source.Bucket tgtBucket := r.Target.Bucket + tgtPrefix := r.Target.Prefix srcObject := srcObjInfo.Name if retry { // when we are retrying avoid copying if necessary. @@ -299,11 +300,11 @@ func (r *BatchJobReplicateV1) ReplicateToTarget(ctx context.Context, api ObjectL } if objInfo.isMultipart() { - if err := replicateObjectWithMultipart(ctx, c, tgtBucket, objInfo.Name, rd, objInfo, putOpts); err != nil { + if err := replicateObjectWithMultipart(ctx, c, tgtBucket, pathJoin(tgtPrefix, objInfo.Name), rd, objInfo, putOpts); err != nil { return err } } else { - if _, err = c.PutObject(ctx, tgtBucket, objInfo.Name, rd, size, "", "", putOpts); err != nil { + if _, err = c.PutObject(ctx, tgtBucket, pathJoin(tgtPrefix, objInfo.Name), rd, size, "", "", putOpts); err != nil { return err } }