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

Method CreateDirInFileMap

pkg/devspace/sync/file_index.go:32–49  ·  view source on GitHub ↗

Function assumes that fileMap is locked for access

(dirpath string)

Source from the content-addressed store, hash-verified

30
31// Function assumes that fileMap is locked for access
32func (f *fileIndex) CreateDirInFileMap(dirpath string) {
33 if dirpath == "/" {
34 return
35 }
36
37 pathParts := strings.Split(dirpath, "/")
38
39 for i := len(pathParts); i > 1; i-- {
40 subPath := strings.Join(pathParts[:i], "/")
41
42 if f.fileMap[subPath] == nil && subPath != "" {
43 f.fileMap[subPath] = &FileInformation{
44 Name: subPath,
45 IsDirectory: true,
46 }
47 }
48 }
49}
50
51// Function assumes that fileMap is locked for access
52// TODO: This function is very expensive O(n), is there a better solution?

Callers 3

untarNextMethod · 0.80
applyCreatesMethod · 0.80
TestCreateDirInFileMapFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestCreateDirInFileMapFunction · 0.64