mirror of
https://github.com/zoriya/flood.git
synced 2026-06-05 03:39:24 +00:00
DiskUsage: ignore mountpoints with super long paths
So things like /var/snap/microk8s/common/run/containerd/ won't spam and jeopardize the disk usage feature. Usually they are very unlikely to be useful.
This commit is contained in:
@@ -57,13 +57,19 @@ class DiskUsage extends (EventEmitter as new () => TypedEmitter<DiskUsageEvents>
|
||||
if (!isPlatformSupported()) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return diskUsage[process.platform as SupportedPlatform]().then((disks) => {
|
||||
if (disks.length !== this.disks.length || disks.some((d, i) => d.used !== this.disks[i].used)) {
|
||||
this.tLastChange = Date.now();
|
||||
this.disks = disks;
|
||||
this.emit('DISK_USAGE_CHANGE', this.getDiskUsage());
|
||||
}
|
||||
});
|
||||
|
||||
return diskUsage[process.platform as SupportedPlatform]()
|
||||
.then((disks) => {
|
||||
// Mountpoints with a very long path are unlikely to be useful.
|
||||
return disks.filter((disk) => disk.target.length < 30);
|
||||
})
|
||||
.then((disks) => {
|
||||
if (disks.length !== this.disks.length || disks.some((d, i) => d.used !== this.disks[i].used)) {
|
||||
this.tLastChange = Date.now();
|
||||
this.disks = disks;
|
||||
this.emit('DISK_USAGE_CHANGE', this.getDiskUsage());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
getDiskUsage(): DiskUsageSummary {
|
||||
|
||||
Reference in New Issue
Block a user