Commit 39d74852 by Octopus Committed by GitHub

fix(storage): swap reversed sourceKey/targetKey args in…

fix(storage): swap reversed sourceKey/targetKey args in OssStorageAdapter.copyObjectInSelfBucket (#6806)

The ali-oss `copy(name, sourceName)` API expects the destination as the
first argument and the source as the second. The previous implementation
passed an encoded sourceKey as the destination and targetKey as the source,
causing copy operations to attempt reading from the target path (which
does not exist yet) and writing to the source path (overwriting the original).

This bug caused custom plugin uploads to fail when using OSS storage, since
the plugin file could not be moved from the temp path to its final location.

Fixes #6787, #6648

Co-authored-by: octo-patch <octo-patch@github.com>
parent eb9df086
...@@ -341,12 +341,7 @@ export class OssStorageAdapter implements IStorage { ...@@ -341,12 +341,7 @@ export class OssStorageAdapter implements IStorage {
async copyObjectInSelfBucket(params: CopyObjectParams): Promise<CopyObjectResult> { async copyObjectInSelfBucket(params: CopyObjectParams): Promise<CopyObjectResult> {
const { sourceKey, targetKey } = params; const { sourceKey, targetKey } = params;
const encodedSourceKey = sourceKey await this.client.copy(targetKey, sourceKey);
.split('/')
.map((segment) => encodeURIComponent(segment))
.join('/');
await this.client.copy(encodedSourceKey, targetKey);
return { return {
bucket: this.options.bucket, bucket: this.options.bucket,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment