Stay compatible with ubuntu's util-linux package
This commit is contained in:
@@ -339,13 +339,14 @@ async function getBlockDevices() {
|
||||
let info;
|
||||
|
||||
try {
|
||||
info = JSON.parse(execSync('lsblk --paths --json --list --noempty', { encoding: 'utf8' }));
|
||||
info = JSON.parse(execSync('lsblk --paths --json --list --bytes', { encoding: 'utf8' }));
|
||||
} catch (e) {
|
||||
console.error('Failed to list disks:', e);
|
||||
throw new BoxError(BoxError.INTERNAL_ERROR, e);
|
||||
}
|
||||
|
||||
const devices = info.blockdevices;
|
||||
// remove empty disks (disks with partitions)
|
||||
const devices = info.blockdevices.filter(d => d.size);
|
||||
|
||||
debug(`getBlockDevices: Found ${devices.length} devices. ${devices.map(d => d.name).join(', ')}`);
|
||||
|
||||
@@ -355,7 +356,7 @@ async function getBlockDevices() {
|
||||
path: d.name,
|
||||
size: d.size,
|
||||
type: d.type,
|
||||
mountpoint: d.mountpoints[0] // we only support one mountpoint here
|
||||
mountpoint: d.mountpoints ? d.mountpoints[0] : d.mountpoint // we only support one mountpoint here old lsblk only exposed one via .mountpoint
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user