Merge pull request #1308 from aluzzardi/semi-atomic-vendoring

semi-atomic vendoring to improve concurrency
This commit is contained in:
Sam Alba
2021-12-23 11:35:13 -08:00
committed by GitHub
2 changed files with 29 additions and 8 deletions

View File

@@ -20,12 +20,7 @@ var (
Path = path.Join("cue.mod", "pkg", ModuleName)
)
func Vendor(ctx context.Context, mod string) error {
// Remove any existing copy of the universe
if err := os.RemoveAll(path.Join(mod, Path)); err != nil {
return err
}
func Vendor(ctx context.Context, dest string) error {
// Write the current version
return fs.WalkDir(FS, ".", func(p string, entry fs.DirEntry, err error) error {
if err != nil {
@@ -45,7 +40,7 @@ func Vendor(ctx context.Context, mod string) error {
return fmt.Errorf("%s: %w", p, err)
}
overlayPath := path.Join(mod, Path, p)
overlayPath := path.Join(dest, p)
if err := os.MkdirAll(filepath.Dir(overlayPath), 0755); err != nil {
return err