(remove []*remote.Change, force bool)
| 395 | } |
| 396 | |
| 397 | func (d *downstream) remove(remove []*remote.Change, force bool) { |
| 398 | d.sync.fileIndex.fileMapMutex.Lock() |
| 399 | defer d.sync.fileIndex.fileMapMutex.Unlock() |
| 400 | |
| 401 | fileMap := d.sync.fileIndex.fileMap |
| 402 | |
| 403 | // Remove Files & Folders |
| 404 | numRemoveFiles := len(remove) |
| 405 | if numRemoveFiles > 3 { |
| 406 | d.sync.log.Infof("Downstream - Remove %d files", numRemoveFiles) |
| 407 | } |
| 408 | |
| 409 | for _, change := range remove { |
| 410 | absFilepath := filepath.Join(d.sync.LocalPath, change.Path) |
| 411 | if shouldRemoveLocal(absFilepath, parseFileInformation(change), d.sync, force) { |
| 412 | if numRemoveFiles <= 3 || d.sync.Options.Verbose { |
| 413 | d.sync.log.Infof("Downstream - Remove '.%s'", change.Path) |
| 414 | } |
| 415 | |
| 416 | if change.IsDir { |
| 417 | d.deleteSafeRecursive(change.Path, remove, force) |
| 418 | } else { |
| 419 | err := os.Remove(absFilepath) |
| 420 | if err != nil { |
| 421 | if !os.IsNotExist(err) { |
| 422 | d.sync.log.Infof("Downstream - Skip file delete '.%s': %v", change.Path, err) |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | delete(fileMap, change.Path) |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | func (d *downstream) deleteSafeRecursive(relativePath string, deleteChanges []*remote.Change, force bool) { |
| 433 | absolutePath := filepath.Join(d.sync.LocalPath, relativePath) |
no test coverage detected