|
|
77f9b1 |
From 2a1dd773a529c89b5f9577b53ae3c88aea2efc48 Mon Sep 17 00:00:00 2001
|
|
|
77f9b1 |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
77f9b1 |
Date: Tue, 17 Jan 2023 20:31:21 +0100
|
|
|
77f9b1 |
Subject: [PATCH] desktop-icons: Don't use blocking IO
|
|
|
77f9b1 |
|
|
|
77f9b1 |
---
|
|
|
77f9b1 |
extensions/desktop-icons/desktopManager.js | 45 +++++++++++++++-------
|
|
|
77f9b1 |
1 file changed, 32 insertions(+), 13 deletions(-)
|
|
|
77f9b1 |
|
|
|
77f9b1 |
diff --git a/extensions/desktop-icons/desktopManager.js b/extensions/desktop-icons/desktopManager.js
|
|
|
77f9b1 |
index 74d0e6bd..75b2a22a 100644
|
|
|
77f9b1 |
--- a/extensions/desktop-icons/desktopManager.js
|
|
|
77f9b1 |
+++ b/extensions/desktop-icons/desktopManager.js
|
|
|
77f9b1 |
@@ -54,6 +54,21 @@ function findMonitorIndexForPos(x, y) {
|
|
|
77f9b1 |
return getDpy().get_monitor_index_for_rect(new Meta.Rectangle({x, y}));
|
|
|
77f9b1 |
}
|
|
|
77f9b1 |
|
|
|
77f9b1 |
+async function queryInfo(file, attributes = DesktopIconsUtil.DEFAULT_ATTRIBUTES, cancellable = null) {
|
|
|
77f9b1 |
+ const flags = Gio.FileQueryInfoFlags.NONE;
|
|
|
77f9b1 |
+ const priority = GLib.PRIORITY_DEFAULT;
|
|
|
77f9b1 |
+ return new Promise((resolve, reject) => {
|
|
|
77f9b1 |
+ file.query_info_async(attributes, flags, priority, cancellable, (o, res) => {
|
|
|
77f9b1 |
+ try {
|
|
|
77f9b1 |
+ const info = file.query_info_finish(res);
|
|
|
77f9b1 |
+ resolve(info);
|
|
|
77f9b1 |
+ } catch (e) {
|
|
|
77f9b1 |
+ reject(e);
|
|
|
77f9b1 |
+ }
|
|
|
77f9b1 |
+ });
|
|
|
77f9b1 |
+ });
|
|
|
77f9b1 |
+}
|
|
|
77f9b1 |
+
|
|
|
77f9b1 |
|
|
|
77f9b1 |
var DesktopManager = GObject.registerClass({
|
|
|
77f9b1 |
Properties: {
|
|
|
77f9b1 |
@@ -272,9 +287,7 @@ var DesktopManager = GObject.registerClass({
|
|
|
77f9b1 |
|
|
|
77f9b1 |
if (!this._unixMode) {
|
|
|
77f9b1 |
let desktopDir = DesktopIconsUtil.getDesktopDir();
|
|
|
77f9b1 |
- let fileInfo = desktopDir.query_info(Gio.FILE_ATTRIBUTE_UNIX_MODE,
|
|
|
77f9b1 |
- Gio.FileQueryInfoFlags.NONE,
|
|
|
77f9b1 |
- null);
|
|
|
77f9b1 |
+ let fileInfo = await queryInfo(desktopDir, Gio.FILE_ATTRIBUTE_UNIX_MODE);
|
|
|
77f9b1 |
this._unixMode = fileInfo.get_attribute_uint32(Gio.FILE_ATTRIBUTE_UNIX_MODE);
|
|
|
77f9b1 |
this._setWritableByOthers((this._unixMode & S_IWOTH) != 0);
|
|
|
77f9b1 |
}
|
|
|
77f9b1 |
@@ -283,7 +296,7 @@ var DesktopManager = GObject.registerClass({
|
|
|
77f9b1 |
let items = [];
|
|
|
77f9b1 |
for (let item of await this._enumerateDesktop())
|
|
|
77f9b1 |
items.push(item);
|
|
|
77f9b1 |
- for (let item of this._getMounts())
|
|
|
77f9b1 |
+ for (let item of await this._getMounts())
|
|
|
77f9b1 |
items.push(item);
|
|
|
77f9b1 |
|
|
|
77f9b1 |
let tmpFileItems = new Map();
|
|
|
77f9b1 |
@@ -328,14 +341,22 @@ var DesktopManager = GObject.registerClass({
|
|
|
77f9b1 |
Gio.FileQueryInfoFlags.NONE,
|
|
|
77f9b1 |
GLib.PRIORITY_DEFAULT,
|
|
|
77f9b1 |
this._desktopEnumerateCancellable,
|
|
|
77f9b1 |
- (source, result) => {
|
|
|
77f9b1 |
+ async (source, result) => {
|
|
|
77f9b1 |
try {
|
|
|
77f9b1 |
let fileEnum = source.enumerate_children_finish(result);
|
|
|
77f9b1 |
+ let extraFolders = await Promise.all(DesktopIconsUtil.getExtraFolders()
|
|
|
77f9b1 |
+ .map(async ([folder, extras]) => {
|
|
|
77f9b1 |
+ const info = await queryInfo(folder,
|
|
|
77f9b1 |
+ DesktopIconsUtil.DEFAULT_ATTRIBUTES,
|
|
|
77f9b1 |
+ this._desktopEnumerateCancellable);
|
|
|
77f9b1 |
+ return [folder, info, extras];
|
|
|
77f9b1 |
+ }));
|
|
|
77f9b1 |
+
|
|
|
77f9b1 |
let resultGenerator = function *() {
|
|
|
77f9b1 |
+ for (let [newFolder, info, extras] of extraFolders)
|
|
|
77f9b1 |
+ yield [newFolder, info, extras];
|
|
|
77f9b1 |
+
|
|
|
77f9b1 |
let info;
|
|
|
77f9b1 |
- for (let [newFolder, extras] of DesktopIconsUtil.getExtraFolders()) {
|
|
|
77f9b1 |
- yield [newFolder, newFolder.query_info(DesktopIconsUtil.DEFAULT_ATTRIBUTES, Gio.FileQueryInfoFlags.NONE, this._desktopEnumerateCancellable), extras];
|
|
|
77f9b1 |
- }
|
|
|
77f9b1 |
while ((info = fileEnum.next_file(null)))
|
|
|
77f9b1 |
yield [fileEnum.get_child(info), info, Prefs.FileType.NONE];
|
|
|
77f9b1 |
}.bind(this);
|
|
|
77f9b1 |
@@ -359,19 +380,17 @@ var DesktopManager = GObject.registerClass({
|
|
|
77f9b1 |
this._monitorDesktopDir.connect('changed', (obj, file, otherFile, eventType) => this._updateDesktopIfChanged(file, otherFile, eventType));
|
|
|
77f9b1 |
}
|
|
|
77f9b1 |
|
|
|
77f9b1 |
- _getMounts() {
|
|
|
77f9b1 |
+ async _getMounts() {
|
|
|
77f9b1 |
let files = [];
|
|
|
77f9b1 |
if (!Prefs.settings.get_boolean('show-mount'))
|
|
|
77f9b1 |
return files;
|
|
|
77f9b1 |
|
|
|
77f9b1 |
- this._mountMonitor.get_mounts().forEach( mount => {
|
|
|
77f9b1 |
+ this._mountMonitor.get_mounts().forEach(async mount => {
|
|
|
77f9b1 |
if (this._isNetworkMount(mount))
|
|
|
77f9b1 |
return;
|
|
|
77f9b1 |
|
|
|
77f9b1 |
let file = mount.get_root();
|
|
|
77f9b1 |
- let info = file.query_info(DesktopIconsUtil.DEFAULT_ATTRIBUTES,
|
|
|
77f9b1 |
- Gio.FileQueryInfoFlags.NONE,
|
|
|
77f9b1 |
- null);
|
|
|
77f9b1 |
+ let info = await queryInfo(file);
|
|
|
77f9b1 |
files.push([file, info, Prefs.FileType.MOUNT_DISK]);
|
|
|
77f9b1 |
});
|
|
|
77f9b1 |
|
|
|
77f9b1 |
--
|
|
|
77f9b1 |
2.38.1
|
|
|
77f9b1 |
|