mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01: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.
|
||||
|
||||
### 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 ###
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 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
|
||||
type ObjectsChan chan Object
|
||||
|
||||
|
@ -1379,3 +1379,12 @@ func listToChan(list *Lister) ObjectsChan {
|
||||
}()
|
||||
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,
|
||||
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",
|
||||
Help: `
|
||||
|
Loading…
Reference in New Issue
Block a user