system: query docker size lazily

This commit is contained in:
Girish Ramakrishnan
2025-07-18 13:05:33 +02:00
parent 25d20266b8
commit 7818219763
+5 -7
View File
@@ -240,18 +240,16 @@ class FilesystemUsageTask extends AsyncTask {
this.emitData({ speed: -1 });
}
const dockerDf = await docker.df({ abortSignal });
let usage = 0;
let usage = 0, dockerDf;
for (const content of contents) {
percent += (90/contents.length+1);
if (abortSignal.aborted) return;
this.emitProgress(percent,`Checking du of ${content.id} ${content.path}`);
if (content.id === 'docker') {
content.usage = dockerDf.LayersSize;
} else if (content.id === 'docker-volumes') {
content.usage = dockerDf.Volumes.map((v) => v.UsageData.Size).reduce((a,b) => a + b, 0);
if (content.id === 'docker' || content.id === 'docker-volumes') {
if (!dockerDf) dockerDf = await docker.df({ abortSignal });
content.usage = content.id === 'docker' ? dockerDf.LayersSize : dockerDf.Volumes.map((v) => v.UsageData.Size).reduce((a,b) => a + b, 0);
} else {
const [error, usage] = await safe(du(content.path, { abortSignal }));
if (error) debug(`du error ${content.path}: ${error.message}`); // can happen if app is installing etc
@@ -261,7 +259,7 @@ class FilesystemUsageTask extends AsyncTask {
this.emitData({ content });
}
if (mountpoint === '/') this.emitData({ type: 'standard', id: 'other', usage: used-usage });
if (mountpoint === '/') this.emitData({ type: 'standard', id: 'os', usage: used-usage });
}
}