From 643eac4a2cba7b34b8a33af1b3dbdc54d9816a53 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 21:30:49 +0200 Subject: plan 9: undo checks trash identity, groups by directory, re-checks at execution, removes directories it recreates --- internal/apply/apply.go | 2 +- internal/apply/fs.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/apply') diff --git a/internal/apply/apply.go b/internal/apply/apply.go index 5624b27..684641e 100644 --- a/internal/apply/apply.go +++ b/internal/apply/apply.go @@ -180,7 +180,7 @@ func runFileStep(step plan.Step) StepResult { return StepResult{Step: step, Status: "failed", Detail: err.Error()} } - made, err := mkdirAllTracked(filepath.Dir(dst)) + made, err := MkdirAllTracked(filepath.Dir(dst)) if err != nil { return StepResult{Step: step, Status: "failed", Detail: err.Error(), Made: made, DisplacedEntry: displacedEntry} } diff --git a/internal/apply/fs.go b/internal/apply/fs.go index 823d5c8..56737e8 100644 --- a/internal/apply/fs.go +++ b/internal/apply/fs.go @@ -201,11 +201,11 @@ func splitExt(name string) (stem, ext string) { return name[:i], name[i:] } -// mkdirAllTracked creates dir and any missing ancestors (mode 0755), +// MkdirAllTracked creates dir and any missing ancestors (mode 0755), // returning every directory it actually created, outermost first, so undo // can later remove the empty ones again. A directory that already existed // is not included, and nothing is created or returned on error. -func mkdirAllTracked(dir string) ([]string, error) { +func MkdirAllTracked(dir string) ([]string, error) { dir = filepath.Clean(dir) if fi, err := os.Stat(dir); err == nil { if !fi.IsDir() { @@ -219,7 +219,7 @@ func mkdirAllTracked(dir string) ([]string, error) { parent := filepath.Dir(dir) var made []string if parent != dir { - parentMade, err := mkdirAllTracked(parent) + parentMade, err := MkdirAllTracked(parent) if err != nil { return nil, err } -- cgit v1.3