core: storage: use soft copy (#830)

This commit is contained in:
undefined authored and GitHub committed 2024-06-22 23:35:07 +08:00
1 parent 82b73a95e0
commit fc2ac23657
4 files changed
+25 -28

No files matched your search

+2 -20
View File
@@ -2,8 +2,8 @@ import { dirname, resolve } from 'path';
import { PassThrough, Readable } from 'stream';
import { URL } from 'url';
import {
CopyObjectCommand, DeleteObjectCommand, DeleteObjectsCommand,
GetObjectCommand, HeadObjectCommand, PutObjectCommand, PutObjectCommandInput, S3Client,
DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand,
HeadObjectCommand, PutObjectCommand, PutObjectCommandInput, S3Client,
} from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
import { createPresignedPost } from '@aws-sdk/s3-presigned-post';
@@ -243,16 +243,6 @@ class RemoteStorageService {
return { url, fields };
}
async copy(src: string, target: string) {
src = convertPath(src);
target = convertPath(target);
return await this.client.send(new CopyObjectCommand({
Bucket: this.bucket,
Key: target,
CopySource: src,
}));
}
async status() {
return {
type: 'S3',
@@ -332,14 +322,6 @@ class LocalStorageService {
throw new Error('Not implemented');
}
async copy(src: string, target: string) {
src = resolve(this.dir, convertPath(src));
target = resolve(this.dir, convertPath(target));
await ensureDir(dirname(target));
await copyFile(src, target);
return { etag: target, lastModified: new Date() };
}
async status() {
return {
type: 'Local',