Codebase list golang-github-google-renameio / 353f819
Symlink: avoid running cleanup twice fixes #18 Michael Stapelberg 4 years ago
2 changed file(s) with 9 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
00 module github.com/google/renameio
1
2 go 1.13
159159 if err != nil {
160160 return err
161161 }
162 defer os.RemoveAll(d)
162 cleanup := true
163 defer func() {
164 if cleanup {
165 os.RemoveAll(d)
166 }
167 }()
163168
164169 symlink := filepath.Join(d, "tmp.symlink")
165170 if err := os.Symlink(oldname, symlink); err != nil {
170175 return err
171176 }
172177
178 cleanup = false
173179 return os.RemoveAll(d)
174180 }