mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
zoho: make upload cutoff configurable
This commit is contained in:
parent
48543d38e8
commit
a2a0388036
@ -41,7 +41,7 @@ const (
|
|||||||
decayConstant = 2 // bigger for slower decay, exponential
|
decayConstant = 2 // bigger for slower decay, exponential
|
||||||
configRootID = "root_folder_id"
|
configRootID = "root_folder_id"
|
||||||
|
|
||||||
largeFileTheshold = 10 * 1024 * 1024 // 10 MiB
|
defaultUploadCutoff = 10 * 1024 * 1024 // 10 MiB
|
||||||
)
|
)
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
@ -214,7 +214,13 @@ browser.`,
|
|||||||
}, {
|
}, {
|
||||||
Value: "com.au",
|
Value: "com.au",
|
||||||
Help: "Australia",
|
Help: "Australia",
|
||||||
}}}, {
|
}},
|
||||||
|
}, {
|
||||||
|
Name: "upload_cutoff",
|
||||||
|
Help: "Cutoff for switching to large file upload api (>= 10 MiB).",
|
||||||
|
Default: fs.SizeSuffix(defaultUploadCutoff),
|
||||||
|
Advanced: true,
|
||||||
|
}, {
|
||||||
Name: config.ConfigEncoding,
|
Name: config.ConfigEncoding,
|
||||||
Help: config.ConfigEncodingHelp,
|
Help: config.ConfigEncodingHelp,
|
||||||
Advanced: true,
|
Advanced: true,
|
||||||
@ -228,6 +234,7 @@ browser.`,
|
|||||||
|
|
||||||
// Options defines the configuration for this backend
|
// Options defines the configuration for this backend
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
UploadCutoff fs.SizeSuffix `config:"upload_cutoff"`
|
||||||
RootFolderID string `config:"root_folder_id"`
|
RootFolderID string `config:"root_folder_id"`
|
||||||
Region string `config:"region"`
|
Region string `config:"region"`
|
||||||
Enc encoder.MultiEncoder `config:"encoding"`
|
Enc encoder.MultiEncoder `config:"encoding"`
|
||||||
@ -493,6 +500,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
if err := configstruct.Set(m, opt); err != nil {
|
if err := configstruct.Set(m, opt); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opt.UploadCutoff < defaultUploadCutoff {
|
||||||
|
return nil, fmt.Errorf("zoho: upload cutoff (%v) must be greater than equal to %v", opt.UploadCutoff, fs.SizeSuffix(defaultUploadCutoff))
|
||||||
|
}
|
||||||
|
|
||||||
err := setupRegion(m)
|
err := setupRegion(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -878,7 +890,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use normal upload API for small sizes (<10MiB)
|
// use normal upload API for small sizes (<10MiB)
|
||||||
if size < largeFileTheshold {
|
if size < int64(f.opt.UploadCutoff) {
|
||||||
info, err := f.upload(ctx, f.opt.Enc.FromStandardName(leaf), directoryID, size, in, options...)
|
info, err := f.upload(ctx, f.opt.Enc.FromStandardName(leaf), directoryID, size, in, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1361,7 +1373,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use normal upload API for small sizes (<10MiB)
|
// use normal upload API for small sizes (<10MiB)
|
||||||
if size < largeFileTheshold {
|
if size < int64(o.fs.opt.UploadCutoff) {
|
||||||
info, err := o.fs.upload(ctx, o.fs.opt.Enc.FromStandardName(leaf), directoryID, size, in, options...)
|
info, err := o.fs.upload(ctx, o.fs.opt.Enc.FromStandardName(leaf), directoryID, size, in, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user