From 86ce6456dcd536bb845af04c6b92fd5f1cc13757 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Apr 2022 10:57:27 +0100 Subject: [PATCH 1/2] extension: Avoid deprecated conversion from Uint8Array to String Previously, this logged a warning: Some code called array.toString() on a Uint8Array instance. Previously this would have interpreted the bytes of the array as a string, but that is nonstandard. In the future this will return the bytes as comma-separated digits. For the time being, the old behavior has been preserved, but please fix your code anyway to explicitly call ByteArray.toString(array). The byteArray module mentioned in the warning is itself non-standard, and in gjs >= 1.70, there is a standard JavaScript replacement for it, the TextEncoder object. For details see . Signed-off-by: Simon McVittie Resolves: https://github.com/biji/harddiskled/issues/14 --- extension.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/extension.js b/extension.js index b759fbf..860003f 100644 --- a/extension.js +++ b/extension.js @@ -25,6 +25,16 @@ let mode; let layoutManager; let ioSpeedStaticIcon; let ioSpeedIcon; +let byteArrayToString; + +if (global.TextDecoder) { + // available in gjs >= 1.70 (GNOME Shell >= 42) + byteArrayToString = (new TextDecoder().decode); +} +else { + // gjs-specific + byteArrayToString = imports.byteArray.toString; +} function init() { cur = 0; @@ -48,8 +58,8 @@ function parseStat(forceDot = false) { let count = 0; let line; - while ((line = dstream.read_line(null))) { - line = String(line); + while (([line, len] = dstream.read_line(null)) != null && line != null) { + line = byteArrayToString(line); let fields = line.split(/ +/); if (fields.length<=2) break; From 74c0406e2e728bff9967fd109a022a44cf94bab2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Apr 2022 10:58:31 +0100 Subject: [PATCH 2/2] metadata: Declare compatibility with GNOME Shell 42 Signed-off-by: Simon McVittie Bug-Debian: https://bugs.debian.org/1008535 --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index add94cd..e0d44af 100644 --- a/metadata.json +++ b/metadata.json @@ -8,7 +8,8 @@ "3.36", "3.38", "40", - "41" + "41", + "42" ], "url": "https://github.com/biji/harddiskled", "uuid": "harddiskled@bijidroid.gmail.com",