Skip to content

Commit d66ea66

Browse files
tursomForSourceCodeAnalysis
authored andcommitted
feat(local): auto create recycle dir if not exists (OpenListTeam#1244)
1 parent ce7a874 commit d66ea66

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
@@ -375,6 +375,13 @@ func (d *Local) Remove(ctx context.Context, obj model.Obj) error {
375375
err = os.Remove(obj.GetPath())
376376
}
377377
} else {
378+
if !utils.Exists(d.RecycleBinPath) {
379+
err = os.MkdirAll(d.RecycleBinPath, 0755)
380+
if err != nil {
381+
return err
382+
}
383+
}
384+
378385
dstPath := filepath.Join(d.RecycleBinPath, obj.GetName())
379386
if utils.Exists(dstPath) {
380387
dstPath = filepath.Join(d.RecycleBinPath, obj.GetName()+"_"+time.Now().Format("20060102150405"))

0 commit comments

Comments
 (0)