mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 17:57:44 +08:00
Implement cleanup command for emptying trash / removing old versions of files
This commit is contained in:
parent
c8e2531c8b
commit
9aae143833
|
@ -197,6 +197,11 @@ don't match. It doesn't alter the source or destination.
|
||||||
|
|
||||||
`--size-only` may be used to only compare the sizes, not the MD5SUMs.
|
`--size-only` may be used to only compare the sizes, not the MD5SUMs.
|
||||||
|
|
||||||
|
### rclone cleanup remote:path ###
|
||||||
|
|
||||||
|
Clean up the remote if possible. Empty the trash or delete old file
|
||||||
|
versions. Not supported by all remotes.
|
||||||
|
|
||||||
### rclone dedupe remote:path ###
|
### rclone dedupe remote:path ###
|
||||||
|
|
||||||
By default `dedup` interactively finds duplicate files and offers to
|
By default `dedup` interactively finds duplicate files and offers to
|
||||||
|
|
9
fs/fs.go
9
fs/fs.go
|
@ -273,6 +273,15 @@ type PutUncheckeder interface {
|
||||||
PutUnchecked(in io.Reader, src ObjectInfo) (Object, error)
|
PutUnchecked(in io.Reader, src ObjectInfo) (Object, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CleanUpper is an optional interfaces for Fs
|
||||||
|
type CleanUpper interface {
|
||||||
|
// CleanUp the trash in the Fs
|
||||||
|
//
|
||||||
|
// Implement this if you have a way of emptying the trash or
|
||||||
|
// otherwise cleaning up old versions of files.
|
||||||
|
CleanUp() error
|
||||||
|
}
|
||||||
|
|
||||||
// ObjectsChan is a channel of Objects
|
// ObjectsChan is a channel of Objects
|
||||||
type ObjectsChan chan Object
|
type ObjectsChan chan Object
|
||||||
|
|
||||||
|
|
|
@ -1379,3 +1379,12 @@ func listToChan(list *Lister) ObjectsChan {
|
||||||
}()
|
}()
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CleanUp removes the trash for the Fs
|
||||||
|
func CleanUp(f Fs) error {
|
||||||
|
fc, ok := f.(CleanUpper)
|
||||||
|
if !ok {
|
||||||
|
return errors.Errorf("%v doesn't support cleanup", f)
|
||||||
|
}
|
||||||
|
return fc.CleanUp()
|
||||||
|
}
|
||||||
|
|
13
rclone.go
13
rclone.go
|
@ -278,6 +278,19 @@ var Commands = []Command{
|
||||||
MinArgs: 1,
|
MinArgs: 1,
|
||||||
MaxArgs: 3,
|
MaxArgs: 3,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "cleanup",
|
||||||
|
ArgsHelp: "remote:path",
|
||||||
|
Help: `
|
||||||
|
Clean up the remote if possible. Empty the trash or delete
|
||||||
|
old file versions. Not supported by all remotes.`,
|
||||||
|
Run: func(fdst, fsrc fs.Fs) error {
|
||||||
|
return fs.CleanUp(fdst)
|
||||||
|
},
|
||||||
|
MinArgs: 1,
|
||||||
|
MaxArgs: 1,
|
||||||
|
Retry: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "help",
|
Name: "help",
|
||||||
Help: `
|
Help: `
|
||||||
|
|
Loading…
Reference in New Issue
Block a user