MCPcopy
hub / github.com/slimtoolkit/slim / rbEnsureGemFiles

Function rbEnsureGemFiles

pkg/app/sensor/artifact/artifact.go:2955–3006  ·  view source on GitHub ↗
(src, storeLocation, prefix string)

Source from the content-addressed store, hash-verified

2953}
2954
2955func rbEnsureGemFiles(src, storeLocation, prefix string) error {
2956 if strings.Contains(src, rbDefaultSpecSubDir) {
2957 return nil
2958 }
2959
2960 dir, file := path.Split(src)
2961 base := strings.TrimSuffix(dir, rbSpecSubDir)
2962 gemName := strings.TrimSuffix(file, rbGemSpecExt)
2963
2964 extBasePath := filepath.Join(base, rgExtSibDir)
2965 foList, err := os.ReadDir(extBasePath)
2966 if err != nil {
2967 return err
2968 }
2969
2970 for _, fo := range foList {
2971 if fo.IsDir() {
2972 platform := fo.Name()
2973
2974 extPlatformPath := filepath.Join(extBasePath, platform)
2975 foVerList, err := os.ReadDir(extPlatformPath)
2976 if err != nil {
2977 return err
2978 }
2979
2980 for _, foVer := range foVerList {
2981 if foVer.IsDir() {
2982 rversion := foVer.Name()
2983
2984 extBuildFlagFilePath := filepath.Join(base, rgExtSibDir, platform, rversion, gemName, rbGemBuildFlag)
2985
2986 if _, err := os.Stat(extBuildFlagFilePath); err != nil && os.IsNotExist(err) {
2987 log.Debug("sensor: monitor - rbEnsureGemFiles - no native extensions for gem =>", gemName)
2988 continue
2989 }
2990
2991 extBuildFlagFilePathDst := fmt.Sprintf("%s%s%s", storeLocation, prefix, extBuildFlagFilePath)
2992
2993 if _, err := os.Stat(extBuildFlagFilePathDst); err != nil && os.IsNotExist(err) {
2994 //if err := cpFile(extBuildFlagFilePath, extBuildFlagFilePathDst); err != nil {
2995 if err := fsutil.CopyRegularFile(true, extBuildFlagFilePath, extBuildFlagFilePathDst, true); err != nil {
2996 log.Debugf("sensor: monitor - rbEnsureGemFiles - error copying file => %v", extBuildFlagFilePathDst)
2997 return err
2998 }
2999 }
3000 }
3001 }
3002 }
3003 }
3004
3005 return nil
3006}
3007
3008type nuxtDirs struct {
3009 Build string

Callers 1

saveArtifactsMethod · 0.85

Calls 3

CopyRegularFileFunction · 0.92
IsDirMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected