mirror of
https://github.com/zoriya/flood.git
synced 2026-06-07 12:24:50 +00:00
server: DiskUsage: increase timeout to 5s
This commit is contained in:
@@ -58,7 +58,7 @@ class DiskUsage extends (EventEmitter as new () => TypedEmitter<DiskUsageEvents>
|
||||
return Promise.reject(new Error());
|
||||
}
|
||||
|
||||
return diskUsage[process.platform as SupportedPlatform]()
|
||||
return diskUsage[process.platform as SupportedPlatform](INTERVAL_UPDATE / 2)
|
||||
.then((disks) => {
|
||||
// Mountpoints with a very long path are unlikely to be useful.
|
||||
return disks.filter((disk) => typeof disk.target === 'string' && disk.target.length < 30);
|
||||
|
||||
@@ -36,12 +36,11 @@ const filterMountPoint = (mountpoint: string) => {
|
||||
};
|
||||
|
||||
const MAX_BUFFER_SIZE = 65536;
|
||||
const EXEC_TIMEOUT = 2000;
|
||||
export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<Disk>>>> = {
|
||||
linux: () =>
|
||||
export const diskUsage: Readonly<Record<SupportedPlatform, (timeout: number) => Promise<Array<Disk>>>> = {
|
||||
linux: (timeout) =>
|
||||
spawnAsync('df', ['-T'], {
|
||||
maxBuffer: MAX_BUFFER_SIZE,
|
||||
timeout: EXEC_TIMEOUT,
|
||||
timeout: timeout,
|
||||
}).then((stdout) =>
|
||||
stdout
|
||||
.trim()
|
||||
@@ -59,10 +58,10 @@ export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<D
|
||||
};
|
||||
}),
|
||||
),
|
||||
freebsd: () =>
|
||||
freebsd: (timeout) =>
|
||||
spawnAsync('df', [], {
|
||||
maxBuffer: MAX_BUFFER_SIZE,
|
||||
timeout: EXEC_TIMEOUT,
|
||||
timeout: timeout,
|
||||
}).then((stdout) =>
|
||||
stdout
|
||||
.trim()
|
||||
@@ -79,10 +78,10 @@ export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<D
|
||||
};
|
||||
}),
|
||||
),
|
||||
darwin: () =>
|
||||
darwin: (timeout) =>
|
||||
spawnAsync('df', ['-kl'], {
|
||||
maxBuffer: MAX_BUFFER_SIZE,
|
||||
timeout: EXEC_TIMEOUT,
|
||||
timeout: timeout,
|
||||
}).then((stdout) =>
|
||||
stdout
|
||||
.trim()
|
||||
@@ -99,10 +98,10 @@ export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<D
|
||||
};
|
||||
}),
|
||||
),
|
||||
win32: () =>
|
||||
win32: (timeout) =>
|
||||
spawnAsync('wmic', ['logicaldisk'], {
|
||||
maxBuffer: MAX_BUFFER_SIZE,
|
||||
timeout: EXEC_TIMEOUT,
|
||||
timeout: timeout,
|
||||
}).then((stdout) =>
|
||||
stdout
|
||||
.trim()
|
||||
|
||||
Reference in New Issue
Block a user