Commit f8ad8c5
Eric Bower
·
2025-12-18 20:23:21 -0500 EST
parent 6819e95
fix(rsync): delete largest path first
1 files changed,
+8,
-0
+8,
-0
| ... | ... | @@ -153,6 +153,14 @@ func (h *handler) Remove(willReceive []*rsyncutils.ReceiverFile) error { | |
| 153 | 153 | } | |
| 154 | 154 | } | |
| 155 | 155 | ||
| 156 | + | // Sort by path depth descending so children are deleted before parents. | |
| 157 | + | // This ensures directories are empty before we try to remove them. | |
| 158 | + | slices.SortFunc(toDelete, func(a, b string) int { | |
| 159 | + | depthA := strings.Count(a, "/") | |
| 160 | + | depthB := strings.Count(b, "/") | |
| 161 | + | return depthB - depthA | |
| 162 | + | }) | |
| 163 | + | ||
| 156 | 164 | var errs []error | |
| 157 | 165 | ||
| 158 | 166 | for _, file := range toDelete { |