From 2e812847572839e6c8097a7ecf5c4a469222087a Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 15 Sep 2026 00:41:00 +0200 Subject: only where an earlier directory's files ended up stays claimed --- cmd/krino/sort.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'cmd/krino/sort.go') diff --git a/cmd/krino/sort.go b/cmd/krino/sort.go index b516629..aeeb1d4 100644 --- a/cmd/krino/sort.go +++ b/cmd/krino/sort.go @@ -264,12 +264,26 @@ func cmdSort(g *globals, names []string, stdout, stderr io.Writer) int { } res, aerr := e.Apply(ctx, toApply, approved, j, run) if res != nil { + // Where files ended up: each copy, and the last place a + // move or rename put the file - not a path it passed + // through and left. for _, fr := range res.Files { + final := "" for _, sr := range fr.Steps { - if sr.Status == "ok" && sr.Dst != "" { + switch { + case sr.Status != "ok": + case sr.Step.Kind == plan.DeletePermanent: + final = "" // gone: nothing is left anywhere + case sr.Dst == "": + case sr.Step.Kind == plan.Copy: applied = append(applied, sr.Dst) + default: + final = sr.Dst } } + if final != "" { + applied = append(applied, final) + } } } if aerr != nil { -- cgit v1.3