system: filesystems in exclude are excluded from content analysis
some disks can be very slow and noisy (at home). this allows users to simply skip them. also, applicable for large storage boxes
This commit is contained in:
+6
-2
@@ -217,7 +217,7 @@ async function getMemory() {
|
||||
}
|
||||
|
||||
async function getDiskUsage() {
|
||||
const cache = safe.JSON.parse(safe.fs.readFileSync(paths.DISK_USAGE_FILE, 'utf8'));
|
||||
const cache = safe.JSON.parse(safe.fs.readFileSync(paths.DISK_USAGE_CACHE_FILE, 'utf8'));
|
||||
if (cache?.disks) {
|
||||
cache.filesystems = cache.disks; // legacy cache file had "disks"
|
||||
delete cache.disks;
|
||||
@@ -234,6 +234,7 @@ async function updateDiskUsage(progressCallback) {
|
||||
let percent = 1;
|
||||
|
||||
const dockerDf = await docker.df();
|
||||
const excludePaths = (safe.fs.readFileSync(paths.DISK_USAGE_EXCLUDE_FILE, 'utf8') || '').split('\n');
|
||||
|
||||
const fsCount = Object.keys(filesystems).length;
|
||||
for (const fsPath in filesystems) {
|
||||
@@ -256,6 +257,9 @@ async function updateDiskUsage(progressCallback) {
|
||||
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);
|
||||
} else if (excludePaths.includes(fsPath)) {
|
||||
debug(`updateDiskUsage: skipping since path ${fsPath} is excluded`);
|
||||
content.usage = 0;
|
||||
} else {
|
||||
const [error, usage] = await safe(du(content.path));
|
||||
if (error) progressCallback({ message: `du error: ${error.message}`}); // can happen if app is installing etc
|
||||
@@ -265,7 +269,7 @@ async function updateDiskUsage(progressCallback) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!safe.fs.writeFileSync(paths.DISK_USAGE_FILE, JSON.stringify({ ts: now, filesystems }, null, 4), 'utf8')) throw new BoxError(BoxError.FS_ERROR, `Could not write du cache file: ${safe.error.message}`);
|
||||
if (!safe.fs.writeFileSync(paths.DISK_USAGE_CACHE_FILE, JSON.stringify({ ts: now, filesystems }, null, 4), 'utf8')) throw new BoxError(BoxError.FS_ERROR, `Could not write du cache file: ${safe.error.message}`);
|
||||
|
||||
return filesystems;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user