MCPcopy Index your code
hub / github.com/devspace-sh/devspace / remove

Method remove

pkg/devspace/sync/downstream.go:397–430  ·  view source on GitHub ↗
(remove []*remote.Change, force bool)

Source from the content-addressed store, hash-verified

395}
396
397func (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
432func (d *downstream) deleteSafeRecursive(relativePath string, deleteChanges []*remote.Change, force bool) {
433 absolutePath := filepath.Join(d.sync.LocalPath, relativePath)

Callers 3

applyChangesMethod · 0.95
preserveExpansionStatesFunction · 0.45
persistStateFunction · 0.45

Calls 7

deleteSafeRecursiveMethod · 0.95
shouldRemoveLocalFunction · 0.85
parseFileInformationFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
RemoveMethod · 0.65
InfofMethod · 0.45

Tested by

no test coverage detected