Skip to content

Commit 1fe26bf

Browse files
authored
feat(local): auto create recycle dir if not exists (#1244)
1 parent 433dcd1 commit 1fe26bf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/local/driver.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,13 @@ func (d *Local) Remove(ctx context.Context, obj model.Obj) error {
374374
err = os.Remove(obj.GetPath())
375375
}
376376
} else {
377+
if !utils.Exists(d.RecycleBinPath) {
378+
err = os.MkdirAll(d.RecycleBinPath, 0755)
379+
if err != nil {
380+
return err
381+
}
382+
}
383+
377384
dstPath := filepath.Join(d.RecycleBinPath, obj.GetName())
378385
if utils.Exists(dstPath) {
379386
dstPath = filepath.Join(d.RecycleBinPath, obj.GetName()+"_"+time.Now().Format("20060102150405"))

0 commit comments

Comments
 (0)