Handle already-existing files correctly
This commit is contained in:
parent
0d38256c5d
commit
decceb85d4
8
s6.go
8
s6.go
|
@ -108,7 +108,7 @@ func (t *S6SvcTree) S6CommitService(s *S6Svc) (err error) {
|
|||
}
|
||||
|
||||
sdir := filepath.Join(t.rcdir, string(s.Name))
|
||||
if err = os.Mkdir(sdir, fs.ModeDir|0777); err != nil {
|
||||
if err = os.Mkdir(sdir, fs.ModeDir|0777); err != nil && !errors.Is(err, os.ErrExist) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ func (t *S6SvcTree) S6CommitService(s *S6Svc) (err error) {
|
|||
|
||||
for _, v := range kvfiles {
|
||||
var f *os.File
|
||||
if f, err = os.OpenFile(filepath.Join(sdir, v.name), os.O_CREATE|os.O_RDWR, fs.FileMode(v.perm)); err != nil && !errors.Is(err, os.ErrExist) {
|
||||
if f, err = os.OpenFile(filepath.Join(sdir, v.name), os.O_CREATE|os.O_RDWR, fs.FileMode(v.perm)); err != nil {
|
||||
return
|
||||
}
|
||||
_, err = fmt.Fprintln(f, v.value)
|
||||
|
@ -167,7 +167,7 @@ func (t *S6SvcTree) S6CommitService(s *S6Svc) (err error) {
|
|||
dirname = "dependencies.d"
|
||||
}
|
||||
cdir := filepath.Join(sdir, dirname)
|
||||
if err = os.Mkdir(cdir, fs.ModeDir|0777); err != nil {
|
||||
if err = os.Mkdir(cdir, fs.ModeDir|0777); err != nil && !errors.Is(err, os.ErrExist) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ func (t *S6SvcTree) S6CommitService(s *S6Svc) (err error) {
|
|||
return
|
||||
}
|
||||
sdir := filepath.Join(t.envdir, string(s.Name))
|
||||
if err = os.Mkdir(sdir, fs.ModeDir|0777); err != nil {
|
||||
if err = os.Mkdir(sdir, fs.ModeDir|0777); err != nil && !errors.Is(err, os.ErrExist) {
|
||||
return
|
||||
}
|
||||
for k, v := range s.env {
|
||||
|
|
Loading…
Reference in New Issue