Browse Source

Merge pull request #1440 from KnicKnic/master

do not rename inuse files
pull/1448/head
Erik Wilson 5 years ago committed by GitHub
parent
commit
b8d8fc3eff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/passwd/passwd.go

6
pkg/passwd/passwd.go

@ -133,6 +133,8 @@ func (p *Passwd) Write(passwdFile string) error {
}
func writePasswords(passwdFile string, records [][]string) error {
err := func() error {
// ensure to close tmp file before rename for filesystems like NTFS
out, err := os.Create(passwdFile + ".tmp")
if err != nil {
return err
@ -143,7 +145,9 @@ func writePasswords(passwdFile string, records [][]string) error {
return err
}
if err := csv.NewWriter(out).WriteAll(records); err != nil {
return csv.NewWriter(out).WriteAll(records)
}()
if err != nil {
return err
}

Loading…
Cancel
Save