s.fileIndex needs to be locked before this function is called
(s *Sync, fileInformation *FileInformation, log log.Logger)
| 37 | |
| 38 | // s.fileIndex needs to be locked before this function is called |
| 39 | func shouldUpload(s *Sync, fileInformation *FileInformation, log log.Logger) bool { |
| 40 | // Exclude if stat is nil |
| 41 | if fileInformation == nil { |
| 42 | return false |
| 43 | } |
| 44 | |
| 45 | // Exclude changes on the upload exclude list |
| 46 | // is not necessary here anymore because it was already |
| 47 | // checked |
| 48 | |
| 49 | // stat.Mode()&os.ModeSymlink |
| 50 | |
| 51 | // Exclude local symlinks |
| 52 | if fileInformation.IsSymbolicLink { |
| 53 | log.Debugf("Don't upload %s because it is a symbolic link", fileInformation.Name) |
| 54 | return false |
| 55 | } |
| 56 | |
| 57 | // Exclude changes on the exclude list |
| 58 | if s.ignoreMatcher != nil && s.ignoreMatcher.Matches(fileInformation.Name, fileInformation.IsDirectory) { |
| 59 | log.Debugf("Don't upload %s because it is excluded", fileInformation.Name) |
| 60 | return false |
| 61 | } |
| 62 | |
| 63 | // Check if we already tracked the path |
| 64 | if s.fileIndex.fileMap[fileInformation.Name] != nil { |
| 65 | // Folder already exists, don't send change |
| 66 | if fileInformation.IsDirectory { |
| 67 | log.Debugf("Don't upload %s because directory already exists", fileInformation.Name) |
| 68 | return false |
| 69 | } |
| 70 | |
| 71 | // Exclude symlinks |
| 72 | if s.fileIndex.fileMap[fileInformation.Name].IsSymbolicLink { |
| 73 | log.Debugf("Don't upload %s because it is a symbolic link", fileInformation.Name) |
| 74 | return false |
| 75 | } |
| 76 | |
| 77 | // File did not change or was changed by downstream |
| 78 | if fileInformation.Mtime == s.fileIndex.fileMap[fileInformation.Name].Mtime && fileInformation.Size == s.fileIndex.fileMap[fileInformation.Name].Size { |
| 79 | log.Debugf("Don't upload %s because mtime and size have not changed", fileInformation.Name) |
| 80 | return false |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return true |
| 85 | } |
| 86 | |
| 87 | // s.fileIndex needs to be locked before this function is called |
| 88 | func shouldDownload(change *remote.Change, s *Sync) bool { |
no test coverage detected