Skip to content

Commit 9910e16

Browse files
committed
fixup! Change install commands to use local assets instead of downloading from github
1 parent a1af974 commit 9910e16

1 file changed

Lines changed: 30 additions & 19 deletions

File tree

shared/services/rocketpool/client.go

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -316,38 +316,49 @@ func (c *Client) runScript(script assets.ScriptWithContext, verbose bool, flags
316316
scriptFile.Close()
317317

318318
// Copy the context to the tmpdir
319-
fs.WalkDir(script.Context, ".", func(path string, d fs.DirEntry, err error) error {
319+
// If we upgrade to go 1.23+ we can probably use os.CopyFS() instead
320+
err = fs.WalkDir(script.Context, ".", func(path string, d fs.DirEntry, err error) error {
320321
if err != nil {
321322
return err
322323
}
323-
// If d is a directory, create it.
324+
dstpath := filepath.Join(tmpdir, path)
324325
if d.IsDir() {
326+
// If d is a directory, create it.
325327
if verbose {
326328
fmt.Printf("Creating directory: %s\n", path)
327329
}
328-
return os.MkdirAll(filepath.Join(tmpdir, path), 0755)
329-
}
330-
// If d is a file, copy it.
331-
if !d.IsDir() {
332-
if verbose {
333-
fmt.Printf("Copying file: %s\n", path)
334-
}
335-
scriptFile, err := os.Create(filepath.Join(tmpdir, path))
330+
err = os.MkdirAll(dstpath, 0755)
336331
if err != nil {
337332
return err
338333
}
339-
content, err := fs.ReadFile(script.Context, path)
340-
if err != nil {
341-
return err
342-
}
343-
_, err = scriptFile.Write(content)
344-
if err != nil {
345-
return err
346-
}
347-
return scriptFile.Close()
334+
return nil
335+
}
336+
337+
// d is a file, copy it.
338+
if verbose {
339+
fmt.Printf("Copying file: %s\n", path)
340+
}
341+
scriptFile, err := os.Create(dstpath)
342+
if err != nil {
343+
return err
344+
}
345+
content, err := fs.ReadFile(script.Context, path)
346+
if err != nil {
347+
return err
348+
}
349+
_, err = scriptFile.Write(content)
350+
if err != nil {
351+
return err
352+
}
353+
err = scriptFile.Close()
354+
if err != nil {
355+
return err
348356
}
349357
return nil
350358
})
359+
if err != nil {
360+
return fmt.Errorf("error copying script files: %w", err)
361+
}
351362

352363
// Initialize command
353364
cmdString := fmt.Sprintf("%s %s", scriptPathName, strings.Join(flags, " "))

0 commit comments

Comments
 (0)