mirror of https://github.com/Xhofe/alist
feat(local): allow specifying the recycle bin path (close #5832)
parent
434892f135
commit
34b73b94f7
|
@ -257,11 +257,19 @@ func (d *Local) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
|
|
||||||
func (d *Local) Remove(ctx context.Context, obj model.Obj) error {
|
func (d *Local) Remove(ctx context.Context, obj model.Obj) error {
|
||||||
var err error
|
var err error
|
||||||
|
if utils.SliceContains([]string{"", "delete permanently"}, d.RecycleBinPath) {
|
||||||
if obj.IsDir() {
|
if obj.IsDir() {
|
||||||
err = os.RemoveAll(obj.GetPath())
|
err = os.RemoveAll(obj.GetPath())
|
||||||
} else {
|
} else {
|
||||||
err = os.Remove(obj.GetPath())
|
err = os.Remove(obj.GetPath())
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ type Addition struct {
|
||||||
ThumbCacheFolder string `json:"thumb_cache_folder"`
|
ThumbCacheFolder string `json:"thumb_cache_folder"`
|
||||||
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
||||||
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
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{
|
var config = driver.Config{
|
||||||
|
|
Loading…
Reference in New Issue