summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefano Facchini <stefano.facchini@gmail.com>2020-05-28 15:37:34 +0200
committerStefano Facchini <stefano.facchini@gmail.com>2020-05-30 09:46:19 +0200
commitac0e9796ef1d9b088e2410f12f2dd82053a98749 (patch)
tree4853a8e2a668d1514bab216fd765b62c15135b65 /src
parent71a8e4a78abaf03d72a591a02f066557c62b0544 (diff)
downloadbaobab-ac0e9796ef1d9b088e2410f12f2dd82053a98749.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/baobab-location.vala27
-rw-r--r--src/baobab-window.vala13
2 files changed, 6 insertions, 34 deletions
diff --git a/src/baobab-location.vala b/src/baobab-location.vala
index ac35490..e1a7b83 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 36f4170..f1cdd49 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -606,20 +606,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);
}