From eb1ee41f44a3d8fefd22b0f30ab2f8a72431fd3f Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 25 Oct 2024 23:54:52 +0200 Subject: [PATCH] Update disklist.js bugfix: Added check to make sure that driveLettersArray is not empty before trying to get drive names. --- "src/\360\237\220\237/disklist.js" | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git "a/src/\360\237\220\237/disklist.js" "b/src/\360\237\220\237/disklist.js" index 8ab81b2..1ddf95a 100644 --- "a/src/\360\237\220\237/disklist.js" +++ "b/src/\360\237\220\237/disklist.js" @@ -109,11 +109,14 @@ class Helpers { } static getDriveLetter(index) { - driveLettersArray.forEach(dl => { // If no drive name, set the name to Unnamed Drive - if (dl.Label === null) dl.Label = "Unnamed Disk"; - }); - return driveLettersArray[index]; + if (driveLettersArray.length > 0) { + driveLettersArray.forEach(dl => { // If no drive name, set the name to Unnamed Drive + if (dl.Label === null) dl.Label = "Unnamed Disk"; + }); + return driveLettersArray[index]; + } } + static getDriveDescription(deviceName) { try { const udevadmOutput = execSync(`udevadm info --query=property --name=${deviceName}`).toString();