diff --git a/model/puller.go b/model/puller.go index 5c525766..f6b9a77a 100644 --- a/model/puller.go +++ b/model/puller.go @@ -245,7 +245,7 @@ func (p *puller) fixupDirectories() { return nil } - if !permsEqual(cur.Flags, uint32(info.Mode())) { + if !scanner.PermsEqual(cur.Flags, uint32(info.Mode())) { err := os.Chmod(path, os.FileMode(cur.Flags)&os.ModePerm) if err != nil { l.Warnln("Restoring folder flags: %q: %v", path, err) diff --git a/model/util.go b/model/util.go index d692006f..e9290531 100644 --- a/model/util.go +++ b/model/util.go @@ -109,15 +109,3 @@ func compareClusterConfig(local, remote protocol.ClusterConfigMessage) error { return nil } - -func permsEqual(a, b uint32) bool { - switch runtime.GOOS { - case "windows": - // There is only writeable and read only, represented for user, group - // and other equally. We only compare against user. - return a&0600 == b&0600 - default: - // All bits count - return a&0777 == b&0777 - } -} diff --git a/scanner/walk.go b/scanner/walk.go index bebd92e4..cb7af346 100644 --- a/scanner/walk.go +++ b/scanner/walk.go @@ -162,7 +162,7 @@ func (w *Walker) walkAndHashFiles(res *[]File, ign map[string][]string) filepath if info.Mode().IsDir() { if w.CurrentFiler != nil { cf := w.CurrentFiler.CurrentFile(rn) - if cf.Modified == info.ModTime().Unix() && protocol.IsDirectory(cf.Flags) && permsEqual(cf.Flags, uint32(info.Mode())) { + if cf.Modified == info.ModTime().Unix() && protocol.IsDirectory(cf.Flags) && PermsEqual(cf.Flags, uint32(info.Mode())) { if debug { l.Debugln("unchanged:", cf) } @@ -186,7 +186,7 @@ func (w *Walker) walkAndHashFiles(res *[]File, ign map[string][]string) filepath if info.Mode().IsRegular() { if w.CurrentFiler != nil { cf := w.CurrentFiler.CurrentFile(rn) - if !protocol.IsDeleted(cf.Flags) && cf.Modified == info.ModTime().Unix() && permsEqual(cf.Flags, uint32(info.Mode())) { + if !protocol.IsDeleted(cf.Flags) && cf.Modified == info.ModTime().Unix() && PermsEqual(cf.Flags, uint32(info.Mode())) { if debug { l.Debugln("unchanged:", cf) } @@ -283,7 +283,7 @@ func checkDir(dir string) error { return nil } -func permsEqual(a, b uint32) bool { +func PermsEqual(a, b uint32) bool { switch runtime.GOOS { case "windows": // There is only writeable and read only, represented for user, group