(newState map[string]*remote.Change, fullPath string)
| 361 | } |
| 362 | |
| 363 | func (d *Downstream) applyChange(newState map[string]*remote.Change, fullPath string) { |
| 364 | fullPath = strings.TrimSuffix(fullPath, "/") |
| 365 | |
| 366 | relativePath := fullPath[len(d.options.RemotePath):] |
| 367 | |
| 368 | // in any case we mark this part of the tree as dirty and delete it |
| 369 | if old, ok := d.watchedFiles[fullPath]; ok { |
| 370 | if old.IsDir { |
| 371 | deletePathFromState(newState, fullPath) |
| 372 | } else { |
| 373 | delete(newState, fullPath) |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | // check if the path still exists |
| 378 | stat, err := os.Stat(fullPath) |
| 379 | if err != nil { |
| 380 | return |
| 381 | } else if d.ignoreMatcher != nil && !d.ignoreMatcher.RequireFullScan() && d.ignoreMatcher.Matches(relativePath, stat.IsDir()) { |
| 382 | return |
| 383 | } |
| 384 | |
| 385 | if stat.IsDir() { |
| 386 | if d.ignoreMatcher == nil || !d.ignoreMatcher.RequireFullScan() || !d.ignoreMatcher.Matches(relativePath, true) { |
| 387 | newState[fullPath] = &remote.Change{ |
| 388 | Path: fullPath, |
| 389 | IsDir: true, |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | walkDir(d.options.RemotePath, fullPath, d.ignoreMatcher, newState, d.options.NoRecursiveWatch, time.Duration(d.options.Throttle)*time.Millisecond) |
| 394 | } else { |
| 395 | if d.ignoreMatcher == nil || !d.ignoreMatcher.RequireFullScan() || !d.ignoreMatcher.Matches(relativePath, false) { |
| 396 | newState[fullPath] = &remote.Change{ |
| 397 | Path: fullPath, |
| 398 | Size: stat.Size(), |
| 399 | MtimeUnix: stat.ModTime().Unix(), |
| 400 | MtimeUnixNano: stat.ModTime().UnixNano(), |
| 401 | Mode: uint32(stat.Mode()), |
| 402 | IsDir: false, |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | func deletePathFromState(state map[string]*remote.Change, path string) { |
| 409 | for k := range state { |
no test coverage detected