lib/config: Handle empty Fstype for mtime-window (#5906)

This commit is contained in:
Simon Frei 2019-07-30 15:23:00 +02:00 committed by GitHub
parent 7d5f7d508d
commit d681ac11fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 10 deletions

View File

@ -248,18 +248,12 @@ func (f *FolderConfiguration) prepare() {
case f.RawModTimeWindowS > 0:
f.cachedModTimeWindow = time.Duration(f.RawModTimeWindowS) * time.Second
case runtime.GOOS == "android":
usage, err := disk.Usage(f.Filesystem().URI())
if err != nil {
l.Debugf("Error detecting FS at %v on android, setting mtime window to 2s: %v", f.Path, err)
if usage, err := disk.Usage(f.Filesystem().URI()); err != nil || usage.Fstype == "" || strings.Contains(strings.ToLower(usage.Fstype), "fat") {
f.cachedModTimeWindow = 2 * time.Second
break
l.Debugf(`Detecting FS at %v on android: Setting mtime window to 2s: err == %v, usage.Fstype == "%v"`, f.Path, err, usage.Fstype)
} else {
l.Debugf(`Detecting FS at %v on android: Leaving mtime window at 0: usage.Fstype == "%v"`, f.Path, usage.Fstype)
}
if strings.Contains(strings.ToLower(usage.Fstype), "fat") {
l.Debugf("Detecting FS at %v on android, found %v, thus setting mtime window to 2s", f.Path, usage.Fstype)
f.cachedModTimeWindow = 2 * time.Second
break
}
l.Debugf("Detecting FS at %v on android, found %v, thus leaving mtime window at 0", f.Path, usage.Fstype)
}
}