diff --git a/drivers/local/driver.go b/drivers/local/driver.go index 04604366f65..4efee6d6c6c 100644 --- a/drivers/local/driver.go +++ b/drivers/local/driver.go @@ -257,10 +257,18 @@ func (d *Local) Copy(ctx context.Context, srcObj, dstDir model.Obj) error { func (d *Local) Remove(ctx context.Context, obj model.Obj) error { var err error - if obj.IsDir() { - err = os.RemoveAll(obj.GetPath()) + if utils.SliceContains([]string{"", "delete permanently"}, d.RecycleBinPath) { + if obj.IsDir() { + err = os.RemoveAll(obj.GetPath()) + } else { + err = os.Remove(obj.GetPath()) + } } else { - err = os.Remove(obj.GetPath()) + dstPath := filepath.Join(d.RecycleBinPath, obj.GetName()) + if utils.Exists(dstPath) { + dstPath = filepath.Join(d.RecycleBinPath, obj.GetName()+"_"+time.Now().Format("20060102150405")) + } + err = os.Rename(obj.GetPath(), dstPath) } if err != nil { return err diff --git a/drivers/local/meta.go b/drivers/local/meta.go index 00c8f5ce8b1..51b49e64ef4 100644 --- a/drivers/local/meta.go +++ b/drivers/local/meta.go @@ -11,6 +11,7 @@ type Addition struct { ThumbCacheFolder string `json:"thumb_cache_folder"` ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"` MkdirPerm string `json:"mkdir_perm" default:"777"` + RecycleBinPath string `json:"recycle_bin_path" default:"delete permanently" help:"path to recycle bin, delete permanently if empty or keep 'delete permanently'"` } var config = driver.Config{