(relativePath, fullPath string)
| 466 | } |
| 467 | |
| 468 | func (u *upstream) evaluateChange(relativePath, fullPath string) ([]*FileInformation, error) { |
| 469 | stat, err := os.Stat(fullPath) |
| 470 | if err != nil { |
| 471 | // Remove symlinks |
| 472 | u.RemoveSymlinks(fullPath) |
| 473 | |
| 474 | // Check if we should remove path remote |
| 475 | if shouldRemoveRemote(relativePath, u.sync) { |
| 476 | // New Remove Task |
| 477 | return []*FileInformation{ |
| 478 | { |
| 479 | Name: relativePath, |
| 480 | }, |
| 481 | }, nil |
| 482 | } |
| 483 | |
| 484 | return nil, nil |
| 485 | } |
| 486 | |
| 487 | // Exclude changes on the upload exclude list |
| 488 | if u.sync.uploadIgnoreMatcher != nil && u.sync.uploadIgnoreMatcher.Matches(relativePath, stat.IsDir()) { |
| 489 | // Add to file map and prevent download if local file is newer than the remote one |
| 490 | if u.sync.fileIndex.fileMap[relativePath] != nil && u.sync.fileIndex.fileMap[relativePath].Mtime < stat.ModTime().Unix() { |
| 491 | // Add it to the fileMap |
| 492 | u.sync.fileIndex.fileMap[relativePath] = &FileInformation{ |
| 493 | Name: relativePath, |
| 494 | Mtime: stat.ModTime().Unix(), |
| 495 | Mode: stat.Mode(), |
| 496 | Size: stat.Size(), |
| 497 | IsDirectory: stat.IsDir(), |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | return nil, nil |
| 502 | } |
| 503 | |
| 504 | // File / Folder exist -> Create File or Folder |
| 505 | // if File / Folder does not exist, we create a new remove change |
| 506 | // Check if symbolic link |
| 507 | lstat, err := os.Lstat(fullPath) |
| 508 | if err == nil && lstat.Mode()&os.ModeSymlink != 0 { |
| 509 | _, symlinkExists := u.sync.upstream.symlinks[fullPath] |
| 510 | |
| 511 | // Add symlink to map |
| 512 | stat, err = u.sync.upstream.AddSymlink(relativePath, fullPath) |
| 513 | if err != nil { |
| 514 | return nil, errors.Wrap(err, "add symlink") |
| 515 | } |
| 516 | if stat == nil { |
| 517 | return nil, nil |
| 518 | } |
| 519 | |
| 520 | // Only crawl if symlink wasn't there before and it is a directory |
| 521 | if !symlinkExists && stat.IsDir() { |
| 522 | // Crawl all linked files & folders |
| 523 | err = u.symlinks[fullPath].Crawl() |
| 524 | if err != nil { |
| 525 | return nil, errors.Wrap(err, "crawl symlink") |
no test coverage detected