mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: support move() and exists() operation
This commit is contained in:
1 file changed
+13
@@ -123,6 +123,19 @@ export class StorageModel {
|
||||
return await storage.signDownloadLink(res.value?.link || res.value?._id || target, filename, noExpire, useAlternativeEndpointFor);
|
||||
}
|
||||
|
||||
static async move(src: string, dst: string) {
|
||||
const res = await StorageModel.coll.findOneAndUpdate(
|
||||
{ path: src, autoDelete: null },
|
||||
{ $set: { path: dst } },
|
||||
);
|
||||
return !!res.value;
|
||||
}
|
||||
|
||||
static async exists(path: string) {
|
||||
const value = await StorageModel.coll.findOne({ path, autoDelete: null });
|
||||
return !!value;
|
||||
}
|
||||
|
||||
static async copy(src: string, dst: string) {
|
||||
const { value } = await StorageModel.coll.findOneAndUpdate(
|
||||
{ path: src, autoDelete: null },
|
||||
|
||||
Reference in new issue
Block a user