Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/plugin-cleaner/src/cleaner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,14 @@ describe('pieces', () => {
})

it('keeps what a timed-out du had counted as a lower bound, and ranks unknown sizes first', () => {
const raw = parseRecords(['META\t1000\tLinux\t1700000000\t0\t/h', 'TOP\t/h/a', 'SIZE\t/h/a\t100\t0', 'TOP\t/h/big', 'SIZE\t/h/big\t5000\t1', 'TOP\t/h/huge', 'SIZE\t/h/huge\t0\t1', 'END'].join('\n'))
const raw = parseRecords(['META\t1000\tLinux\t1700000000\t0\t/h', 'TOP\t/h/a', 'SIZE\t/h/a\t100\t0', 'TOP\t/h/big', 'SIZE\t/h/big\t5000\t1', 'TOP\t/h/huge', 'SIZE\t/h/huge\t0\t1', 'TOP\t/h/complete', 'SIZE\t/h/complete\t90000\t0', 'TOP\t/h/slow', 'SIZE\t/h/slow\t10\t1', 'END'].join('\n'))
const report = buildReport(raw, { target: 'local', idleDays: 3, partialHours: 24, journalCap: '1G', imageAge: '72h', useSudo: false })
// A folder du could not finish lists before any finished one, even with a tiny lower bound.
expect(report.topDirs.map((d) => [d.path, d.bytes, d.timedOut])).toEqual([
['/h/huge', -1, true],
['/h/big', 5000 * 1024, true],
['/h/slow', 10 * 1024, true],
['/h/complete', 90000 * 1024, false],
['/h/a', 100 * 1024, false],
])
})
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-cleaner/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,9 @@ export function buildReport(raw: Raw, options: BuildOptions): Report {
const bytes = size(path)
return { path, bytes, timedOut: bytes < 0 || raw.partial.has(path), kind: classifyDir(path, raw.dockerRoot) }
})
// Unknown first (it ran out of time with nothing counted, so it may be the biggest), then by size; a lower bound counts as its size.
.sort((a, b) => (b.bytes < 0 ? Infinity : b.bytes) - (a.bytes < 0 ? Infinity : a.bytes))
// Anything du could not finish first: it may well be the biggest, and a small lower bound
// (du counted for 20 s before giving up) must not push it off the list. Then by size.
.sort((a, b) => Number(b.timedOut) - Number(a.timedOut) || (b.bytes < 0 ? Infinity : b.bytes) - (a.bytes < 0 ? Infinity : a.bytes))

for (const dir of topDirs) {
if (!dir.kind || !REVIEW_WHY[dir.kind]) continue
Expand Down
Loading