Blame SOURCES/0001-desktop-icons-Don-t-use-blocking-IO.patch

f60408
From 93e3e938b322433aff862bbc46f80c60ab7dc2ab Mon Sep 17 00:00:00 2001
f60408
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
f60408
Date: Tue, 17 Jan 2023 20:31:21 +0100
f60408
Subject: [PATCH] desktop-icons: Don't use blocking IO
f60408
f60408
---
f60408
 extensions/desktop-icons/desktopManager.js | 35 +++++++++++++++++-----
f60408
 1 file changed, 28 insertions(+), 7 deletions(-)
f60408
f60408
diff --git a/extensions/desktop-icons/desktopManager.js b/extensions/desktop-icons/desktopManager.js
f60408
index 399aee03..2ce6eefb 100644
f60408
--- a/extensions/desktop-icons/desktopManager.js
f60408
+++ b/extensions/desktop-icons/desktopManager.js
f60408
@@ -53,6 +53,21 @@ function findMonitorIndexForPos(x, y) {
f60408
     return getDpy().get_monitor_index_for_rect(new Meta.Rectangle({x, y}));
f60408
 }
f60408
 
f60408
+async function queryInfo(file, attributes = DesktopIconsUtil.DEFAULT_ATTRIBUTES, cancellable = null) {
f60408
+    const flags = Gio.FileQueryInfoFlags.NONE;
f60408
+    const priority = GLib.PRIORITY_DEFAULT;
f60408
+    return new Promise((resolve, reject) => {
f60408
+        file.query_info_async(attributes, flags, priority, cancellable, (o, res) => {
f60408
+            try {
f60408
+                const info = file.query_info_finish(res);
f60408
+                resolve(info);
f60408
+            } catch (e) {
f60408
+                reject(e);
f60408
+            }
f60408
+        });
f60408
+    });
f60408
+}
f60408
+
f60408
 
f60408
 var DesktopManager = GObject.registerClass({
f60408
     Properties: {
f60408
@@ -221,9 +236,7 @@ var DesktopManager = GObject.registerClass({
f60408
 
f60408
         if (!this._unixMode) {
f60408
             let desktopDir = DesktopIconsUtil.getDesktopDir();
f60408
-            let fileInfo = desktopDir.query_info(Gio.FILE_ATTRIBUTE_UNIX_MODE,
f60408
-                                                 Gio.FileQueryInfoFlags.NONE,
f60408
-                                                 null);
f60408
+            let fileInfo = await queryInfo(desktopDir, Gio.FILE_ATTRIBUTE_UNIX_MODE);
f60408
             this._unixMode = fileInfo.get_attribute_uint32(Gio.FILE_ATTRIBUTE_UNIX_MODE);
f60408
             this._setWritableByOthers((this._unixMode & S_IWOTH) != 0);
f60408
         }
f60408
@@ -268,14 +281,22 @@ var DesktopManager = GObject.registerClass({
f60408
                 Gio.FileQueryInfoFlags.NONE,
f60408
                 GLib.PRIORITY_DEFAULT,
f60408
                 this._desktopEnumerateCancellable,
f60408
-                (source, result) => {
f60408
+                async (source, result) => {
f60408
                     try {
f60408
                         let fileEnum = source.enumerate_children_finish(result);
f60408
+                        let extraFolders = await Promise.all(DesktopIconsUtil.getExtraFolders()
f60408
+                            .map(async ([folder, extras]) => {
f60408
+                                const info = await queryInfo(folder,
f60408
+                                    DesktopIconsUtil.DEFAULT_ATTRIBUTES,
f60408
+                                    this._desktopEnumerateCancellable);
f60408
+                                return [folder, info, extras];
f60408
+                            }));
f60408
+
f60408
                         let resultGenerator = function *() {
f60408
+                            for (let [newFolder, info, extras] of extraFolders)
f60408
+                                yield [newFolder, info, extras];
f60408
+
f60408
                             let info;
f60408
-                            for (let [newFolder, extras] of DesktopIconsUtil.getExtraFolders()) {
f60408
-                                yield [newFolder, newFolder.query_info(DesktopIconsUtil.DEFAULT_ATTRIBUTES, Gio.FileQueryInfoFlags.NONE, this._desktopEnumerateCancellable), extras];
f60408
-                            }
f60408
                             while ((info = fileEnum.next_file(null)))
f60408
                                 yield [fileEnum.get_child(info), info, Prefs.FileType.NONE];
f60408
                         }.bind(this);
f60408
-- 
f60408
2.38.1
f60408