(absPath string, localState map[string]*FileInformation, ignore bool)
| 271 | } |
| 272 | |
| 273 | func (i *initialSyncer) CalculateLocalState(absPath string, localState map[string]*FileInformation, ignore bool) error { |
| 274 | relativePath := getRelativeFromFullPath(absPath, i.o.LocalPath) |
| 275 | |
| 276 | // We skip files that are suddenly not there anymore |
| 277 | stat, err := os.Stat(absPath) |
| 278 | if err != nil { |
| 279 | return nil |
| 280 | } |
| 281 | |
| 282 | // Exclude changes on the upload exclude list |
| 283 | if i.o.UploadIgnoreMatcher != nil { |
| 284 | if i.o.UploadIgnoreMatcher.Matches(relativePath, stat.IsDir()) { |
| 285 | ignore = true |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | // Check for symlinks |
| 290 | isSymlink := false |
| 291 | if !ignore { |
| 292 | // Retrieve the real stat instead of the symlink one |
| 293 | lstat, err := os.Lstat(absPath) |
| 294 | if err == nil && lstat.Mode()&os.ModeSymlink != 0 { |
| 295 | // Get real path |
| 296 | targetPath, err := filepath.EvalSymlinks(absPath) |
| 297 | if err != nil { |
| 298 | return nil |
| 299 | } |
| 300 | |
| 301 | stat, err = os.Stat(targetPath) |
| 302 | if err != nil { |
| 303 | return nil |
| 304 | } |
| 305 | |
| 306 | isSymlink = true |
| 307 | } else if err != nil { |
| 308 | return nil |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | // Check if stat is somehow not there |
| 313 | if stat == nil { |
| 314 | return nil |
| 315 | } else if i.o.IgnoreMatcher != nil && !i.o.IgnoreMatcher.RequireFullScan() && i.o.IgnoreMatcher.Matches(relativePath, stat.IsDir()) { |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | if stat.IsDir() { |
| 320 | return i.calculateLocalDirState(absPath, stat, localState, isSymlink, ignore) |
| 321 | } |
| 322 | |
| 323 | if !ignore { |
| 324 | // Add file to upload |
| 325 | localState[relativePath] = &FileInformation{ |
| 326 | Name: relativePath, |
| 327 | Mtime: stat.ModTime().Unix(), |
| 328 | MtimeNano: stat.ModTime().UnixNano(), |
| 329 | Size: stat.Size(), |
| 330 | Mode: stat.Mode(), |
no test coverage detected