Skip to content

Commit f2efb38

Browse files
barbatos2011Barbatos
authored andcommitted
fix(fsclone): check os.RemoveAll error in cleanup defer (errcheck)
golangci-lint errcheck flagged the bare `defer os.RemoveAll(tmp)`. Wrap it to explicitly discard the error — best-effort temp cleanup whose failure is non-actionable. (Missed locally: ran go vet, not the full golangci-lint.)
1 parent 9ddb1b5 commit f2efb38

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

internal/fsclone/clone.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ func CloneDir(src, dst string) (method string, err error) {
8989
if mkErr != nil {
9090
return "", fmt.Errorf("fsclone: create staging dir in %s: %w", parent, mkErr)
9191
}
92-
defer os.RemoveAll(tmp) // removes the empty husk after rename, or the partial tree on error
92+
// Removes the empty husk after a successful rename, or the partial
93+
// tree on error. Best-effort temp cleanup — a failure here is
94+
// non-actionable, so the error is deliberately discarded.
95+
defer func() { _ = os.RemoveAll(tmp) }()
9396
staged := filepath.Join(tmp, "payload")
9497

9598
method = cloneMethodName

0 commit comments

Comments
 (0)