(events []notify.EventInfo)
| 431 | } |
| 432 | |
| 433 | func (u *upstream) getFileInformationFromEvent(events []notify.EventInfo) ([]*FileInformation, error) { |
| 434 | u.sync.fileIndex.fileMapMutex.Lock() |
| 435 | defer u.sync.fileIndex.fileMapMutex.Unlock() |
| 436 | |
| 437 | changes := make([]*FileInformation, 0, len(events)) |
| 438 | for _, event := range events { |
| 439 | fileInfo, ok := event.(*FileInformation) |
| 440 | |
| 441 | // if the change is sent from the initial sync don't evaluate it |
| 442 | if ok { |
| 443 | changes = append(changes, fileInfo) |
| 444 | } else { |
| 445 | u.sync.log.Debugf("Upstream - Event from filesystem for %s", event.Path()) |
| 446 | |
| 447 | // check if path is correct |
| 448 | fullPath := event.Path() |
| 449 | if !strings.HasPrefix(filepath.ToSlash(fullPath), filepath.ToSlash(u.sync.LocalPath)+"/") { |
| 450 | u.sync.log.Infof("Upstream - unexpected upload path %s", fullPath) |
| 451 | continue |
| 452 | } |
| 453 | |
| 454 | // Determine what kind of change we got (Create or Remove) |
| 455 | relativePath := getRelativeFromFullPath(fullPath, u.sync.LocalPath) |
| 456 | newChanges, err := u.evaluateChange(relativePath, fullPath) |
| 457 | if err != nil { |
| 458 | return nil, errors.Wrap(err, "evaluate change") |
| 459 | } |
| 460 | |
| 461 | changes = append(changes, newChanges...) |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | return changes, nil |
| 466 | } |
| 467 | |
| 468 | func (u *upstream) evaluateChange(relativePath, fullPath string) ([]*FileInformation, error) { |
| 469 | stat, err := os.Stat(fullPath) |
no test coverage detected