mirror of
https://github.com/rclone/rclone.git
synced 2025-02-14 21:23:01 +02:00
jottacloud: implement --jottacloud-trashed-only
This commit is contained in:
parent
da41db4712
commit
2c2f4a6a05
@ -140,6 +140,11 @@ func init() {
|
|||||||
Help: "Files bigger than this will be cached on disk to calculate the MD5 if required.",
|
Help: "Files bigger than this will be cached on disk to calculate the MD5 if required.",
|
||||||
Default: fs.SizeSuffix(10 * 1024 * 1024),
|
Default: fs.SizeSuffix(10 * 1024 * 1024),
|
||||||
Advanced: true,
|
Advanced: true,
|
||||||
|
}, {
|
||||||
|
Name: "trashed_only",
|
||||||
|
Help: "Only show files that are in the trash.\nThis will show trashed files in their original directory structure.",
|
||||||
|
Default: false,
|
||||||
|
Advanced: true,
|
||||||
}, {
|
}, {
|
||||||
Name: "hard_delete",
|
Name: "hard_delete",
|
||||||
Help: "Delete files permanently rather than putting them into the trash.",
|
Help: "Delete files permanently rather than putting them into the trash.",
|
||||||
@ -174,6 +179,7 @@ type Options struct {
|
|||||||
Device string `config:"device"`
|
Device string `config:"device"`
|
||||||
Mountpoint string `config:"mountpoint"`
|
Mountpoint string `config:"mountpoint"`
|
||||||
MD5MemoryThreshold fs.SizeSuffix `config:"md5_memory_limit"`
|
MD5MemoryThreshold fs.SizeSuffix `config:"md5_memory_limit"`
|
||||||
|
TrashedOnly bool `config:"trashed_only"`
|
||||||
HardDelete bool `config:"hard_delete"`
|
HardDelete bool `config:"hard_delete"`
|
||||||
Unlink bool `config:"unlink"`
|
Unlink bool `config:"unlink"`
|
||||||
UploadThreshold fs.SizeSuffix `config:"upload_resume_limit"`
|
UploadThreshold fs.SizeSuffix `config:"upload_resume_limit"`
|
||||||
@ -519,6 +525,9 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
|
|||||||
WriteMimeType: true,
|
WriteMimeType: true,
|
||||||
}).Fill(f)
|
}).Fill(f)
|
||||||
f.srv.SetErrorHandler(errorHandler)
|
f.srv.SetErrorHandler(errorHandler)
|
||||||
|
if opt.TrashedOnly { // we cannot support showing Trashed Files when using ListR right now
|
||||||
|
f.features.ListR = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Renew the token in the background
|
// Renew the token in the background
|
||||||
f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error {
|
f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error {
|
||||||
@ -638,13 +647,13 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
|
|||||||
return nil, errors.Wrap(err, "couldn't list files")
|
return nil, errors.Wrap(err, "couldn't list files")
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.Deleted {
|
if bool(result.Deleted) && !f.opt.TrashedOnly {
|
||||||
return nil, fs.ErrorDirNotFound
|
return nil, fs.ErrorDirNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range result.Folders {
|
for i := range result.Folders {
|
||||||
item := &result.Folders[i]
|
item := &result.Folders[i]
|
||||||
if item.Deleted {
|
if !f.opt.TrashedOnly && bool(item.Deleted) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
remote := path.Join(dir, f.opt.Enc.ToStandardName(item.Name))
|
remote := path.Join(dir, f.opt.Enc.ToStandardName(item.Name))
|
||||||
@ -654,8 +663,14 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
|
|||||||
|
|
||||||
for i := range result.Files {
|
for i := range result.Files {
|
||||||
item := &result.Files[i]
|
item := &result.Files[i]
|
||||||
if item.Deleted || item.State != "COMPLETED" {
|
if f.opt.TrashedOnly {
|
||||||
continue
|
if !item.Deleted || item.State != "COMPLETED" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if item.Deleted || item.State != "COMPLETED" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
remote := path.Join(dir, f.opt.Enc.ToStandardName(item.Name))
|
remote := path.Join(dir, f.opt.Enc.ToStandardName(item.Name))
|
||||||
o, err := f.newObjectWithInfo(ctx, remote, item)
|
o, err := f.newObjectWithInfo(ctx, remote, item)
|
||||||
@ -1122,7 +1137,7 @@ func (o *Object) readMetaData(ctx context.Context, force bool) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if info.Deleted {
|
if bool(info.Deleted) && !o.fs.opt.TrashedOnly {
|
||||||
return fs.ErrorObjectNotFound
|
return fs.ErrorObjectNotFound
|
||||||
}
|
}
|
||||||
return o.setMetaData(info)
|
return o.setMetaData(info)
|
||||||
|
@ -174,6 +174,16 @@ Files bigger than this will be cached on disk to calculate the MD5 if required.
|
|||||||
- Type: SizeSuffix
|
- Type: SizeSuffix
|
||||||
- Default: 10M
|
- Default: 10M
|
||||||
|
|
||||||
|
#### --jottacloud-trashed-only
|
||||||
|
|
||||||
|
Only show files that are in the trash.
|
||||||
|
This will show trashed files in their original directory structure.
|
||||||
|
|
||||||
|
- Config: trashed_only
|
||||||
|
- Env Var: RCLONE_JOTTACLOUD_TRASHED_ONLY
|
||||||
|
- Type: bool
|
||||||
|
- Default: false
|
||||||
|
|
||||||
#### --jottacloud-hard-delete
|
#### --jottacloud-hard-delete
|
||||||
|
|
||||||
Delete files permanently rather than putting them into the trash.
|
Delete files permanently rather than putting them into the trash.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user