MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / copyLocalDirContents

Function copyLocalDirContents

agent/app/service/agents_skills.go:587–612  ·  view source on GitHub ↗
(sourceRoot, targetRoot string)

Source from the content-addressed store, hash-verified

585}
586
587func copyLocalDirContents(sourceRoot, targetRoot string) error {
588 return filepath.Walk(sourceRoot, func(sourcePath string, info os.FileInfo, err error) error {
589 if err != nil {
590 return err
591 }
592 if sourcePath == sourceRoot {
593 return nil
594 }
595 if info.Mode()&os.ModeSymlink != 0 || (!info.IsDir() && !info.Mode().IsRegular()) {
596 return fmt.Errorf("unsupported skill package entry: %s", sourcePath)
597 }
598 rel, err := filepath.Rel(sourceRoot, sourcePath)
599 if err != nil {
600 return err
601 }
602 name, err := safeLocalSkillZipEntryName(rel)
603 if err != nil {
604 return err
605 }
606 targetPath := filepath.Join(targetRoot, name)
607 if info.IsDir() {
608 return os.MkdirAll(targetPath, info.Mode())
609 }
610 return copyLocalSkillFile(sourcePath, targetPath)
611 })
612}
613
614func copyLocalSkillFile(source, target string) error {
615 src, err := os.Open(source)

Callers 2

un7zLocalSkillPackageFunction · 0.85

Calls 5

copyLocalSkillFileFunction · 0.85
ModeMethod · 0.80
IsDirMethod · 0.80
MkdirAllMethod · 0.80

Tested by

no test coverage detected