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

Method calculateLocalDirState

pkg/devspace/sync/initial.go:340–380  ·  view source on GitHub ↗
(absPath string, stat os.FileInfo, localState map[string]*FileInformation, isSymlink, ignore bool)

Source from the content-addressed store, hash-verified

338}
339
340func (i *initialSyncer) calculateLocalDirState(absPath string, stat os.FileInfo, localState map[string]*FileInformation, isSymlink, ignore bool) error {
341 relativePath := getRelativeFromFullPath(absPath, i.o.LocalPath)
342 files, err := os.ReadDir(absPath)
343 if err != nil {
344 i.o.Log.Infof("Couldn't read dir %s: %v", absPath, err)
345 return nil
346 }
347
348 if relativePath != "" && !ignore && stat != nil {
349 localState[relativePath] = &FileInformation{
350 Name: relativePath,
351 Mtime: stat.ModTime().Unix(),
352 MtimeNano: stat.ModTime().UnixNano(),
353 Size: stat.Size(),
354 Mode: stat.Mode(),
355 IsDirectory: true,
356 IsSymbolicLink: stat.Mode()&os.ModeSymlink != 0,
357 ResolvedLink: isSymlink,
358 Files: len(files),
359 }
360 }
361
362 for _, dirEntry := range files {
363 f, err := dirEntry.Info()
364 if err != nil {
365 continue
366 }
367
368 if fsutil.IsRecursiveSymlink(f, filepath.Join(absPath, f.Name())) {
369 i.o.Log.Debugf("Found recursive symlink at %v", filepath.Join(absPath, f.Name()))
370 continue
371 }
372
373 err = i.CalculateLocalState(filepath.Join(absPath, f.Name()), localState, ignore)
374 if err != nil {
375 return errors.Wrap(err, f.Name())
376 }
377 }
378
379 return nil
380}
381
382type action int
383

Callers 1

CalculateLocalStateMethod · 0.95

Calls 10

CalculateLocalStateMethod · 0.95
IsRecursiveSymlinkFunction · 0.92
getRelativeFromFullPathFunction · 0.70
NameMethod · 0.65
InfofMethod · 0.45
ModTimeMethod · 0.45
SizeMethod · 0.45
ModeMethod · 0.45
InfoMethod · 0.45
DebugfMethod · 0.45

Tested by

no test coverage detected