Fix crash when system has no swap
This commit is contained in:
+3
-1
@@ -70,9 +70,11 @@ async function hdparm(file) {
|
||||
async function getSwaps() {
|
||||
const [error, stdout] = await safe(shell.exec('getSwaps', 'swapon --noheadings --raw --bytes --show=type,size,used,name', {}));
|
||||
if (error) return {};
|
||||
const output = stdout.trim();
|
||||
if (!output) return {}; // no swaps
|
||||
|
||||
const swaps = {};
|
||||
for (const line of stdout.trim().split('\n')) {
|
||||
for (const line of output.split('\n')) {
|
||||
const parts = line.split(' ', 4);
|
||||
const name = parts[3];
|
||||
swaps[name] = {
|
||||
|
||||
Reference in New Issue
Block a user