@@ -75,12 +75,12 @@ func shouldUpload(relativePath string, stat os.FileInfo, s *SyncConfig, isInitia
7575
7676 if isInitial {
7777 // File is older locally than remote so don't update remote
78- if ceilMtime (stat .ModTime ()) <= s .fileIndex .fileMap [relativePath ].Mtime + 1 {
78+ if roundMtime (stat .ModTime ()) <= s .fileIndex .fileMap [relativePath ].Mtime {
7979 return false
8080 }
8181 } else {
8282 // File did not change or was changed by downstream
83- if ceilMtime (stat .ModTime ()) == s .fileIndex .fileMap [relativePath ].Mtime && stat .Size () == s .fileIndex .fileMap [relativePath ].Size {
83+ if roundMtime (stat .ModTime ()) == s .fileIndex .fileMap [relativePath ].Mtime && stat .Size () == s .fileIndex .fileMap [relativePath ].Size {
8484 return false
8585 }
8686 }
@@ -140,35 +140,47 @@ func shouldDownload(fileInformation *fileInformation, s *SyncConfig) bool {
140140// - The file is present on the filesystem and did not change in terms of size and mtime on the filesystem
141141func shouldRemoveLocal (absFilepath string , fileInformation * fileInformation , s * SyncConfig ) bool {
142142 if fileInformation == nil {
143+ s .Logf ("Skip %s because fileInformation is nil" , absFilepath )
143144 return false
144145 }
145146
147+ // We don't need to check s.ignoreMatcher, because if a path is ignored it will never be added to the fileMap, because shouldDownload
148+ // and shouldUpload are always false, and hence it never appears in the fileMap and is not copied to the remove fileMap clone
149+ // in the beginning of the downstream mainLoop
150+
146151 // Exclude files on the exclude list
147152 if s .downloadIgnoreMatcher != nil {
148153 if s .downloadIgnoreMatcher .MatchesPath (fileInformation .Name ) {
154+ s .Logf ("Skip %s because downloadIgnoreMatcher matched" , absFilepath )
149155 return false
150156 }
151157 }
152158
153159 // Only delete if mtime and size did not change
154160 stat , err := os .Stat (absFilepath )
155161 if err != nil {
162+ s .Logf ("Skip %s because stat returned %v" , absFilepath , stat )
156163 return false
157164 }
158165
159166 // We don't delete the file if we haven't tracked it
160167 if stat != nil && s .fileIndex .fileMap [fileInformation .Name ] != nil {
161168 if stat .IsDir () != s .fileIndex .fileMap [fileInformation .Name ].IsDirectory || stat .IsDir () != fileInformation .IsDirectory {
169+ s .Logf ("Skip %s because stat returned unequal isdir with fileMap" , absFilepath )
162170 return false
163171 }
164172
165173 if fileInformation .IsDirectory == false {
166174 // We don't delete the file if it has changed in the map since we collected changes
167175 if fileInformation .Mtime == s .fileIndex .fileMap [fileInformation .Name ].Mtime && fileInformation .Size == s .fileIndex .fileMap [fileInformation .Name ].Size {
168176 // We don't delete the file if it has changed on the filesystem meanwhile
169- if ceilMtime (stat .ModTime ()) <= fileInformation .Mtime {
177+ if roundMtime (stat .ModTime ()) <= fileInformation .Mtime {
170178 return true
171179 }
180+
181+ s .Logf ("Skip %s because stat.ModTime() %d is greater than fileInformation.Mtime %d" , absFilepath , roundMtime (stat .ModTime ()), fileInformation .Mtime )
182+ } else {
183+ s .Logf ("Skip %s because Mtime (%d and %d) or Size (%d and %d) is unequal between fileInformation and fileMap" , absFilepath , fileInformation .Mtime , s .fileIndex .fileMap [fileInformation .Name ].Mtime , fileInformation .Size , s .fileIndex .fileMap [fileInformation .Name ].Size )
172184 }
173185 } else {
174186 return true
0 commit comments