[baobab] Stop scanning when crossing device boundaries, not mount points
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab] Stop scanning when crossing device boundaries, not mount points
- Date: Fri, 12 Jun 2020 10:18:18 +0000 (UTC)
commit 1d7d1cc4413add96d9259ed0075b95080d9502f5
Author: Stefano Facchini <stefano facchini gmail com>
Date: Wed Jun 10 23:11:36 2020 +0200
Stop scanning when crossing device boundaries, not mount points
The previous behavior was: if the EXCLUDE_MOUNTS flag is set, stop scanning
whenever a mount point is encountered, or any of the paths listed in the
'excluded-uris' setting; otherwise, scan the directory.
Now the scanner *always* excludes the locations listed in 'excluded-uris'. If
the EXCLUDE_MOUNTS flag is set, it stops when a directory is on a different
unix device. This is more consistent with other similar tools, and behaves
better in an OSTree system.
Closes: https://gitlab.gnome.org/GNOME/baobab/-/issues/32
src/baobab-application.vala | 15 +++------------
src/baobab-scanner.vala | 14 +++++---------
2 files changed, 8 insertions(+), 21 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index a92bb1c..50492ef 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -62,20 +62,11 @@ namespace Baobab {
public GenericSet<File> get_excluded_locations () {
var excluded_locations = new GenericSet<File> (File.hash, File.equal);
- excluded_locations.add (File.new_for_path ("/proc"));
- excluded_locations.add (File.new_for_path ("/sys"));
- excluded_locations.add (File.new_for_path ("/selinux"));
- var home = File.new_for_path (Environment.get_home_dir ());
- excluded_locations.add (home.get_child (".gvfs"));
-
- var root = File.new_for_path ("/");
var prefs_settings = new Settings ("org.gnome.baobab.preferences");
- foreach (var uri in prefs_settings.get_value ("excluded-uris")) {
- var file = File.new_for_uri ((string) uri);
- if (!file.equal (root)) {
- excluded_locations.add (file);
- }
+ foreach (var uri in prefs_settings.get_strv ("excluded-uris")) {
+ var file = File.new_for_uri (uri);
+ excluded_locations.add (file);
}
return excluded_locations;
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 7b9b41b..9db09ea 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -95,6 +95,7 @@ namespace Baobab {
GenericSet<HardLink> hardlinks;
GenericSet<File> excluded_locations;
+ uint32 unix_device = 0;
bool successful = false;
@@ -171,7 +172,9 @@ namespace Baobab {
Results? add_directory (File directory, FileInfo info, Results? parent = null) {
var results_array = new ResultsArray ();
- if (directory in excluded_locations) {
+ var current_unix_device = info.get_attribute_uint32 (FileAttribute.UNIX_DEVICE);
+ if (directory in excluded_locations ||
+ (ScanFlags.EXCLUDE_MOUNTS in scan_flags && current_unix_device != unix_device)) {
return null;
}
@@ -267,6 +270,7 @@ namespace Baobab {
try {
var array = new ResultsArray ();
var info = directory.query_info (ATTRIBUTES, 0, cancellable);
+ unix_device = info.get_attribute_uint32 (FileAttribute.UNIX_DEVICE);
var results = add_directory (directory, info);
results.percent = 100.0;
array.results += (owned) results;
@@ -443,14 +447,6 @@ namespace Baobab {
excluded_locations = Application.get_default ().get_excluded_locations ();
- if (ScanFlags.EXCLUDE_MOUNTS in flags) {
- foreach (unowned UnixMountEntry mount in UnixMountEntry.get (null)) {
- excluded_locations.add (File.new_for_path (mount.get_mount_path ()));
- }
- }
-
- excluded_locations.remove (directory);
-
results_queue = new AsyncQueue<ResultsArray> ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]