core: fix copy error (#777)

This commit is contained in:
panda authored and GitHub committed 2024-04-05 17:23:14 +08:00
1 parent 18faad5510
commit 6454e2ed96
2 files changed
+2 -1

No files matched your search

+1 -1
View File
@@ -106,7 +106,7 @@ export class StorageModel {
// Make sure id is not used
// eslint-disable-next-line no-await-in-loop
while (await StorageModel.coll.findOne({ _id })) _id = StorageModel.generateId(extname(dst));
const result = await storage.copy(value._id, dst);
const result = await storage.copy(value._id, _id);
const { metaData, size, etag } = await storage.getMeta(_id);
await StorageModel.coll.insertOne({
_id, meta: metaData, path: dst, size, etag, lastModified: new Date(), owner: value.owner || 1,
+1
View File
@@ -335,6 +335,7 @@ class LocalStorageService {
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() };
}