1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-15 15:53:41 +00:00

fs: calculate ModifyWindow each time on the fly instead of relying on global state - see #2319, #2328

This commit is contained in:
Stefan
2018-06-03 20:45:34 +02:00
committed by GitHub
parent 3ef938ebde
commit 4009fb67c8
9 changed files with 43 additions and 83 deletions

View File

@@ -862,23 +862,20 @@ func FileExists(fs Fs, remote string) (bool, error) {
return true, nil
}
// CalculateModifyWindow works out modify window for Fses passed in -
// sets Config.ModifyWindow
//
// This is the largest modify window of all the fses in use, and the
// user configured value
func CalculateModifyWindow(fss ...Fs) {
// GetModifyWindow calculates the maximum modify window between the given Fses
// and the Config.ModifyWindow parameter.
func GetModifyWindow(fss ...Info) time.Duration {
window := Config.ModifyWindow
for _, f := range fss {
if f != nil {
precision := f.Precision()
if precision > Config.ModifyWindow {
Config.ModifyWindow = precision
}
if precision == ModTimeNotSupported {
Infof(f, "Modify window not supported")
return
return ModTimeNotSupported
}
if precision > window {
window = precision
}
}
}
Infof(fss[0], "Modify window is %s", Config.ModifyWindow)
return window
}