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