[baobab/gnome-3-34] location: stop querying file info
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/gnome-3-34] location: stop querying file info
- Date: Tue, 23 Jun 2020 08:12:09 +0000 (UTC)
commit 35ae1d4f2db69f2d226230cd80e39caa21e76e0e
Author: Stefano Facchini <stefano facchini gmail com>
Date: Thu May 28 15:37:34 2020 +0200
location: stop querying file info
It is actually never used. The Location returned from Location.for_file is temporary and
never added to the location list.
This should avoid a blocking call in case of slow remote mounts.
src/baobab-location.vala | 27 ---------------------------
src/baobab-window.vala | 13 ++++++-------
2 files changed, 6 insertions(+), 34 deletions(-)
---
diff --git a/src/baobab-location.vala b/src/baobab-location.vala
index 433c8a6..b0028ba 100644
--- a/src/baobab-location.vala
+++ b/src/baobab-location.vala
@@ -30,7 +30,6 @@ namespace Baobab {
public class Location {
public string name { get; private set; }
public File? file { get; private set; }
- public FileInfo? info { get; private set; }
public uint64? size { get; private set; }
public uint64? used { get; private set; }
@@ -54,11 +53,6 @@ namespace Baobab {
FileAttribute.FILESYSTEM_SIZE + "," +
FileAttribute.FILESYSTEM_USED;
- private const string FILE_ATTRIBUTES =
- FileAttribute.STANDARD_DISPLAY_NAME + "," +
- FileAttribute.STANDARD_ICON + "," +
- FileAttribute.STANDARD_TYPE;
-
string get_hostname () throws Error {
HostnameIface hostname_iface;
hostname_iface = Bus.get_proxy_sync (BusType.SYSTEM,
@@ -79,7 +73,6 @@ namespace Baobab {
public Location.for_home_folder () {
file = File.new_for_path (GLib.Environment.get_home_dir ());
- get_file_info ();
make_this_home_location ();
@@ -117,7 +110,6 @@ namespace Baobab {
}
file = File.new_for_path ("/");
- get_file_info ();
icon = new ThemedIcon.with_default_fallbacks ("drive-harddisk-system");
is_main_volume = true;
@@ -137,15 +129,6 @@ namespace Baobab {
public Location.for_file (File file_, ScanFlags flags) {
file = file_;
- get_file_info ();
-
- if (info != null) {
- name = info.get_display_name ();
- icon = info.get_icon ();
- } else {
- name = file_.get_parse_name ();
- icon = null;
- }
scanner = new Scanner (file, flags);
}
@@ -165,7 +148,6 @@ namespace Baobab {
name = volume.get_name ();
icon = volume.get_icon ();
file = null;
- info = null;
size = null;
used = null;
scanner = null;
@@ -176,7 +158,6 @@ namespace Baobab {
name = mount.get_name ();
icon = mount.get_icon ();
file = mount.get_root ();
- get_file_info ();
if (file != null && file.equal (File.new_for_path (Environment.get_home_dir ()))) {
make_this_home_location ();
@@ -187,14 +168,6 @@ namespace Baobab {
scanner = new Scanner (file, ScanFlags.EXCLUDE_MOUNTS);
}
- void get_file_info () {
- try {
- info = file.query_info (FILE_ATTRIBUTES, FileQueryInfoFlags.NONE, null);
- } catch (Error e) {
- info = null;
- }
- }
-
void start_fs_usage_timeout () {
queue_query_fs_usage ();
Timeout.add_seconds(2, (() => {
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index f6da4cb..5d4fef0 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -612,20 +612,19 @@ namespace Baobab {
}
public void scan_directory (File directory, ScanFlags flags=ScanFlags.NONE) {
- var location = new Location.for_file (directory, flags);
-
- if (location.info == null) {
- var primary = _("ā%sā is not a valid folder").printf (directory.get_parse_name ());
- message (primary, _("Could not analyze disk usage."), Gtk.MessageType.ERROR);
- return;
+ FileInfo info = null;
+ try {
+ info = directory.query_info (FileAttribute.STANDARD_TYPE, FileQueryInfoFlags.NONE, null);
+ } catch (Error e) {
}
- if (location.info.get_file_type () != FileType.DIRECTORY/* || is_virtual_filesystem ()*/) {
+ if (info == null || info.get_file_type () != FileType.DIRECTORY) {
var primary = _("ā%sā is not a valid folder").printf (directory.get_parse_name ());
message (primary, _("Could not analyze disk usage."), Gtk.MessageType.ERROR);
return;
}
+ var location = new Location.for_file (directory, flags);
set_active_location (location);
scan_active_location (false);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]