feat: make sure internal path is mkdir before download
Fix https://github.com/haunt98/dotfiles/issues/26main
parent
1d3635053b
commit
22ff5073d1
|
@ -69,6 +69,13 @@ func (c *configReal) Download() error {
|
||||||
return fmt.Errorf("io: failed to read all: %w", err)
|
return fmt.Errorf("io: failed to read all: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy from github.com/make-go-great/copy-go
|
||||||
|
// Make sure nested dir is exist before copying file
|
||||||
|
dstDir := filepath.Dir(p.Internal)
|
||||||
|
if err := os.MkdirAll(dstDir, os.ModePerm); err != nil {
|
||||||
|
return fmt.Errorf("failed to mkdir %s: %w", dstDir, err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(p.Internal, data, 0o600); err != nil {
|
if err := os.WriteFile(p.Internal, data, 0o600); err != nil {
|
||||||
return fmt.Errorf("os: failed to write file: %w", err)
|
return fmt.Errorf("os: failed to write file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue