mirror of
https://github.com/rclone/rclone.git
synced 2025-01-13 20:38:12 +02:00
dropbox,ftp,onedrive,yandex: make --timeout 0 work properly
See: https://forum.rclone.org/t/an-issue-about-ftp-backend-in-2-different-systems/22551
This commit is contained in:
parent
9cc8ff4dd4
commit
0ad38dd6fa
@ -1269,7 +1269,7 @@ func (f *Fs) changeNotifyRunner(ctx context.Context, notifyFunc func(string, fs.
|
|||||||
var res *files.ListFolderLongpollResult
|
var res *files.ListFolderLongpollResult
|
||||||
|
|
||||||
// Dropbox sets a timeout range of 30 - 480
|
// Dropbox sets a timeout range of 30 - 480
|
||||||
timeout := uint64(f.ci.Timeout / time.Second)
|
timeout := uint64(f.ci.TimeoutOrInfinite() / time.Second)
|
||||||
if timeout > 480 {
|
if timeout > 480 {
|
||||||
timeout = 480
|
timeout = 480
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for List for up to Timeout seconds
|
// Wait for List for up to Timeout seconds
|
||||||
timer := time.NewTimer(f.ci.Timeout)
|
timer := time.NewTimer(f.ci.TimeoutOrInfinite())
|
||||||
select {
|
select {
|
||||||
case listErr = <-errchan:
|
case listErr = <-errchan:
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
|
@ -1088,7 +1088,7 @@ func (f *Fs) Precision() time.Duration {
|
|||||||
|
|
||||||
// waitForJob waits for the job with status in url to complete
|
// waitForJob waits for the job with status in url to complete
|
||||||
func (f *Fs) waitForJob(ctx context.Context, location string, o *Object) error {
|
func (f *Fs) waitForJob(ctx context.Context, location string, o *Object) error {
|
||||||
deadline := time.Now().Add(f.ci.Timeout)
|
deadline := time.Now().Add(f.ci.TimeoutOrInfinite())
|
||||||
for time.Now().Before(deadline) {
|
for time.Now().Before(deadline) {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var err error
|
var err error
|
||||||
@ -1126,7 +1126,7 @@ func (f *Fs) waitForJob(ctx context.Context, location string, o *Object) error {
|
|||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
return errors.Errorf("async operation didn't complete after %v", f.ci.Timeout)
|
return errors.Errorf("async operation didn't complete after %v", f.ci.TimeoutOrInfinite())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy src to this remote using server-side copy operations.
|
// Copy src to this remote using server-side copy operations.
|
||||||
|
@ -537,7 +537,7 @@ func (f *Fs) waitForJob(ctx context.Context, location string) (err error) {
|
|||||||
RootURL: location,
|
RootURL: location,
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
}
|
}
|
||||||
deadline := time.Now().Add(f.ci.Timeout)
|
deadline := time.Now().Add(f.ci.TimeoutOrInfinite())
|
||||||
for time.Now().Before(deadline) {
|
for time.Now().Before(deadline) {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var body []byte
|
var body []byte
|
||||||
@ -568,7 +568,7 @@ func (f *Fs) waitForJob(ctx context.Context, location string) (err error) {
|
|||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
return errors.Errorf("async operation didn't complete after %v", f.ci.Timeout)
|
return errors.Errorf("async operation didn't complete after %v", f.ci.TimeoutOrInfinite())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fs) delete(ctx context.Context, path string, hardDelete bool) (err error) {
|
func (f *Fs) delete(ctx context.Context, path string, hardDelete bool) (err error) {
|
||||||
|
@ -164,6 +164,14 @@ func NewConfig() *ConfigInfo {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TimeoutOrInfinite returns ci.Timeout if > 0 or infinite otherwise
|
||||||
|
func (c *ConfigInfo) TimeoutOrInfinite() time.Duration {
|
||||||
|
if c.Timeout > 0 {
|
||||||
|
return c.Timeout
|
||||||
|
}
|
||||||
|
return ModTimeNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
type configContextKeyType struct{}
|
type configContextKeyType struct{}
|
||||||
|
|
||||||
// Context key for config
|
// Context key for config
|
||||||
|
Loading…
Reference in New Issue
Block a user