aboutsummaryrefslogtreecommitdiff
path: root/internal/plan/chain.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 21:27:22 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 21:27:22 +0200
commitaca389f0e63713b890214cad950ac3aee7e6aaf4 (patch)
treebb4dab94ca594edb339ab8fd1743d583efe3d59c /internal/plan/chain.go
parent3bfafbc8664a2a1ba8efc3f64376ff63c3dc11b9 (diff)
downloadkrino-aca389f0e63713b890214cad950ac3aee7e6aaf4.tar.gz
krino-aca389f0e63713b890214cad950ac3aee7e6aaf4.zip
plan 9: overwrite never trashes a directory or another scanned file
Diffstat (limited to 'internal/plan/chain.go')
-rw-r--r--internal/plan/chain.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/plan/chain.go b/internal/plan/chain.go
index d4d07da..793e0e1 100644
--- a/internal/plan/chain.go
+++ b/internal/plan/chain.go
@@ -68,6 +68,14 @@ func Build(root string, in []Input, now time.Time, d Disk, claims *Claims) []Cha
return in[order[i]].File.Rel < in[order[j]].File.Rel
})
+ // Every scanned file's own path counts as spoken for (review M4): no step
+ // of this plan may trash another scanned file to make room - it may be
+ // about to move away, or be acted on by its own chain - so overwrite
+ // takes a free name there, exactly as suffix already did for a path that
+ // exists on disk.
+ for _, x := range in {
+ claims.taken[x.File.Path] = true
+ }
chains := make([]Chain, len(in))
for _, i := range order {
chains[i] = buildOne(root, in[i], now, d, claims.taken)