[baobab/reroot-view: 44/48] Throw only on errors for the location, not subdirectories



commit 3823e452703ad9ffa56c11be1c43ce4511008aca
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Jun 18 22:19:46 2020 +0200

    Throw only on errors for the location, not subdirectories

 src/baobab-scanner.vala |  6 +-----
 src/baobab-window.vala  | 32 ++++++++++++++++++++------------
 2 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 389284d..69d1fd9 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -377,12 +377,8 @@ namespace Baobab {
                         max_depth = results.max_depth;
                     }
 
-                    // Report the first error we encountered
-                    if (results.error != null && scan_error == null) {
-                        scan_error = results.error;
-                    }
-
                     if (results.parent == null) {
+                        scan_error = results.error;
                         successful = true;
                         completed ();
                         return false;
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index bd6c92f..4e00b6a 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -153,6 +153,7 @@ namespace Baobab {
         private Location? active_location = null;
         private ulong scan_completed_handler = 0;
         private uint scanning_progress_id = 0;
+        private uint scanning_page_timeout_id = 0;
 
         static Gdk.Cursor busy_cursor;
 
@@ -325,6 +326,11 @@ namespace Baobab {
                 scan_completed_handler = 0;
             }
 
+            if (scanning_page_timeout_id > 0) {
+                Source.remove (scanning_page_timeout_id);
+                scanning_page_timeout_id = 0;
+            }
+
             active_location = null;
         }
 
@@ -620,23 +626,20 @@ namespace Baobab {
                 scanning_progress_id = 0;
             }
 
+            if (scanning_page_timeout_id > 0) {
+                Source.remove (scanning_page_timeout_id);
+                scanning_page_timeout_id = 0;
+            }
+
             try {
                 scanner.finish();
             } catch (IOError.CANCELLED e) {
                 // Handle cancellation silently
                 return;
             } catch (Error e) {
-                Gtk.TreeIter iter;
-                Scanner.State state;
-                scanner.get_iter_first (out iter);
-                scanner.get (iter, Scanner.Columns.STATE, out state);
-                if (state == Scanner.State.ERROR) {
-                    var primary = _("Could not scan folder “%s”").printf (scanner.directory.get_parse_name 
());
-                    message (primary, e.message, Gtk.MessageType.ERROR);
-                } else {
-                    var primary = _("Could not scan some of the folders contained in “%s”").printf 
(scanner.directory.get_parse_name ());
-                    message (primary, e.message, Gtk.MessageType.WARNING);
-                }
+                var primary = _("Could not scan folder “%s”").printf (scanner.directory.get_parse_name ());
+                message (primary, e.message, Gtk.MessageType.ERROR);
+                return;
             }
 
             reroot_treeview (new Gtk.TreePath.first ());
@@ -674,7 +677,12 @@ namespace Baobab {
             scan_completed_handler = scanner.completed.connect (scanner_completed);
 
             clear_message ();
-            set_ui_state (scanning_page, true);
+
+            scanning_page_timeout_id = Timeout.add (200, () => {
+                scanning_page_timeout_id = 0;
+                set_ui_state (scanning_page, true);
+                return Source.REMOVE;
+            });
 
             scanning_progress_id = Timeout.add (100, () => {
                 scanning_progress_label.label = format_size (scanner.total_size);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]