forked from TrueCloudLab/rclone
jottacloud: add no versions option
This commit is contained in:
parent
94b1439299
commit
8652cfe575
2 changed files with 38 additions and 5 deletions
|
@ -99,6 +99,11 @@ func init() {
|
||||||
Help: "Files bigger than this can be resumed if the upload fail's.",
|
Help: "Files bigger than this can be resumed if the upload fail's.",
|
||||||
Default: fs.SizeSuffix(10 * 1024 * 1024),
|
Default: fs.SizeSuffix(10 * 1024 * 1024),
|
||||||
Advanced: true,
|
Advanced: true,
|
||||||
|
}, {
|
||||||
|
Name: "no_versions",
|
||||||
|
Help: "Avoid server side versioning by deleting files and recreating files instead of overwriting them.",
|
||||||
|
Default: false,
|
||||||
|
Advanced: true,
|
||||||
}, {
|
}, {
|
||||||
Name: config.ConfigEncoding,
|
Name: config.ConfigEncoding,
|
||||||
Help: config.ConfigEncodingHelp,
|
Help: config.ConfigEncodingHelp,
|
||||||
|
@ -297,6 +302,7 @@ type Options struct {
|
||||||
MD5MemoryThreshold fs.SizeSuffix `config:"md5_memory_limit"`
|
MD5MemoryThreshold fs.SizeSuffix `config:"md5_memory_limit"`
|
||||||
TrashedOnly bool `config:"trashed_only"`
|
TrashedOnly bool `config:"trashed_only"`
|
||||||
HardDelete bool `config:"hard_delete"`
|
HardDelete bool `config:"hard_delete"`
|
||||||
|
NoVersions bool `config:"no_versions"`
|
||||||
UploadThreshold fs.SizeSuffix `config:"upload_resume_limit"`
|
UploadThreshold fs.SizeSuffix `config:"upload_resume_limit"`
|
||||||
Enc encoder.MultiEncoder `config:"encoding"`
|
Enc encoder.MultiEncoder `config:"encoding"`
|
||||||
}
|
}
|
||||||
|
@ -1494,6 +1500,20 @@ func readMD5(in io.Reader, size, threshold int64) (md5sum string, out io.Reader,
|
||||||
//
|
//
|
||||||
// The new object may have been created if an error is returned
|
// The new object may have been created if an error is returned
|
||||||
func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) {
|
func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) {
|
||||||
|
if o.fs.opt.NoVersions {
|
||||||
|
err := o.readMetaData(ctx, false)
|
||||||
|
if err == nil {
|
||||||
|
// if the object exists delete it
|
||||||
|
err = o.remove(ctx, true)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to remove old object")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the object does not exist we can just continue but if the error is something different we should report that
|
||||||
|
if err != fs.ErrorObjectNotFound {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
o.fs.tokenRenewer.Start()
|
o.fs.tokenRenewer.Start()
|
||||||
defer o.fs.tokenRenewer.Stop()
|
defer o.fs.tokenRenewer.Stop()
|
||||||
size := src.Size()
|
size := src.Size()
|
||||||
|
@ -1584,8 +1604,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove an object
|
func (o *Object) remove(ctx context.Context, hard bool) error {
|
||||||
func (o *Object) Remove(ctx context.Context) error {
|
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: o.filePath(),
|
Path: o.filePath(),
|
||||||
|
@ -1593,7 +1612,7 @@ func (o *Object) Remove(ctx context.Context) error {
|
||||||
NoResponse: true,
|
NoResponse: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.fs.opt.HardDelete {
|
if hard {
|
||||||
opts.Parameters.Set("rm", "true")
|
opts.Parameters.Set("rm", "true")
|
||||||
} else {
|
} else {
|
||||||
opts.Parameters.Set("dl", "true")
|
opts.Parameters.Set("dl", "true")
|
||||||
|
@ -1605,6 +1624,11 @@ func (o *Object) Remove(ctx context.Context) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove an object
|
||||||
|
func (o *Object) Remove(ctx context.Context) error {
|
||||||
|
return o.remove(ctx, o.fs.opt.HardDelete)
|
||||||
|
}
|
||||||
|
|
||||||
// Check the interfaces are satisfied
|
// Check the interfaces are satisfied
|
||||||
var (
|
var (
|
||||||
_ fs.Fs = (*Fs)(nil)
|
_ fs.Fs = (*Fs)(nil)
|
||||||
|
|
|
@ -213,7 +213,7 @@ Files bigger than this will be cached on disk to calculate the MD5 if required.
|
||||||
- Config: md5_memory_limit
|
- Config: md5_memory_limit
|
||||||
- Env Var: RCLONE_JOTTACLOUD_MD5_MEMORY_LIMIT
|
- Env Var: RCLONE_JOTTACLOUD_MD5_MEMORY_LIMIT
|
||||||
- Type: SizeSuffix
|
- Type: SizeSuffix
|
||||||
- Default: 10M
|
- Default: 10Mi
|
||||||
|
|
||||||
#### --jottacloud-trashed-only
|
#### --jottacloud-trashed-only
|
||||||
|
|
||||||
|
@ -241,7 +241,16 @@ Files bigger than this can be resumed if the upload fail's.
|
||||||
- Config: upload_resume_limit
|
- Config: upload_resume_limit
|
||||||
- Env Var: RCLONE_JOTTACLOUD_UPLOAD_RESUME_LIMIT
|
- Env Var: RCLONE_JOTTACLOUD_UPLOAD_RESUME_LIMIT
|
||||||
- Type: SizeSuffix
|
- Type: SizeSuffix
|
||||||
- Default: 10M
|
- Default: 10Mi
|
||||||
|
|
||||||
|
#### --jottacloud-no-versions
|
||||||
|
|
||||||
|
Avoid server side versioning by deleting files and recreating files instead of overwriting them.
|
||||||
|
|
||||||
|
- Config: no_versions
|
||||||
|
- Env Var: RCLONE_JOTTACLOUD_NO_VERSIONS
|
||||||
|
- Type: bool
|
||||||
|
- Default: false
|
||||||
|
|
||||||
#### --jottacloud-encoding
|
#### --jottacloud-encoding
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue