diff --git a/cmd/mount.go b/cmd/mount.go index 05b6d6132abb..fb464f437c5a 100644 --- a/cmd/mount.go +++ b/cmd/mount.go @@ -283,6 +283,7 @@ func getVfsConf(c *cli.Context, metaConf *meta.Config, format *meta.Format, chun PPid: os.Getppid(), UMask: 0xFFFF, HideInternal: c.Bool("hide-internal"), + SkipTrash: c.Bool("skip-trash"), } if c.IsSet("umask") { diff --git a/cmd/mount_unix.go b/cmd/mount_unix.go index 4425f3560089..2cb1022ffe3f 100644 --- a/cmd/mount_unix.go +++ b/cmd/mount_unix.go @@ -393,6 +393,10 @@ func mountFlags() []cli.Flag { Name: "hide-internal", Usage: "hide all internal files (.accesslog, .stats, etc.)", }, + &cli.BoolFlag{ + Name: "skip-trash", + Usage: "skip trash and delete files directly", + }, } if runtime.GOOS == "linux" { selfFlags = append(selfFlags, &cli.BoolFlag{ diff --git a/pkg/vfs/vfs.go b/pkg/vfs/vfs.go index a722e962e57b..7cf4833fd319 100644 --- a/pkg/vfs/vfs.go +++ b/pkg/vfs/vfs.go @@ -144,6 +144,7 @@ type Config struct { AllSquash *AnonymousAccount `json:",omitempty"` NonDefaultPermission bool `json:",omitempty"` UMask uint16 + SkipTrash bool `json:",omitempty"` Pid int PPid int @@ -276,7 +277,7 @@ func (v *VFS) Unlink(ctx Context, parent Ino, name string) (err syscall.Errno) { err = syscall.ENAMETOOLONG return } - err = v.Meta.Unlink(ctx, parent, name) + err = v.Meta.Unlink(ctx, parent, name, v.Conf.SkipTrash) if err == 0 { v.invalidateDirHandle(parent, name, 0, nil) } @@ -312,7 +313,7 @@ func (v *VFS) Rmdir(ctx Context, parent Ino, name string) (err syscall.Errno) { err = syscall.ENAMETOOLONG return } - err = v.Meta.Rmdir(ctx, parent, name) + err = v.Meta.Rmdir(ctx, parent, name, v.Conf.SkipTrash) if err == 0 { v.invalidateDirHandle(parent, name, 0, nil) }