[baobab/wip/vala: 43/53] Handle scanning error without aborting the scan
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 43/53] Handle scanning error without aborting the scan
- Date: Thu, 5 Apr 2012 22:05:10 +0000 (UTC)
commit 4a335938844355b94193c9e63e818fbf18bfcde8
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Feb 5 14:43:13 2012 +0100
Handle scanning error without aborting the scan
Errors encountered during now show a warning in the info bar, but do not
completely abort the scan. Errors are stored in the model but are not
yet shown in the treeview.
src/baobab-scanner.vala | 5 ++++-
src/baobab-threaded-scanner.vala | 21 ++++++++++++++-------
src/baobab-window.vala | 6 ++----
3 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 81f0ff1..86fd177 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -28,6 +28,7 @@ namespace Baobab {
ALLOC_SIZE,
ELEMENTS,
STATE,
+ ERROR,
COLUMNS
}
@@ -35,6 +36,7 @@ namespace Baobab {
SCANNING,
CANCELLED,
NEED_PERCENT,
+ ERROR,
DONE
}
@@ -93,7 +95,8 @@ namespace Baobab {
typeof (uint64), // SIZE
typeof (uint64), // ALLOC_SIZE
typeof (int), // ELEMENTS
- typeof (State)}); // STATE
+ typeof (State), // STATE
+ typeof (Error)}); // ERROR (if STATE is ERROR)
set_sort_column_id (Columns.SIZE, Gtk.SortType.DESCENDING);
excluded_locations = Application.get_excluded_locations ();
}
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index 3199b42..019c730 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -219,18 +219,25 @@ namespace Baobab {
Columns.ALLOC_SIZE, results.alloc_size,
Columns.PERCENT, results.percent,
Columns.ELEMENTS, results.elements,
- Columns.STATE, State.DONE);
+ Columns.STATE, results.error == null ? State.DONE : State.ERROR,
+ Columns.ERROR, results.error);
if (results.max_depth > max_depth) {
max_depth = results.max_depth;
}
- // only on the first error
- if (scan_error == null && results.error != null) {
- scan_error = results.error;
- cancellable.cancel ();
- completed ();
- return false;
+ // If the user cancelled abort the scan and
+ // report CANCELLED as the error, otherwise
+ // consider the error not fatal and report the
+ // first error we encountered
+ if (results.error != null) {
+ if (results.error is IOError.CANCELLED) {
+ scan_error = results.error;
+ completed ();
+ return false;
+ } else if (scan_error == null) {
+ scan_error = results.error;
+ }
}
if (results.parent == null) {
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index a1a32dd..9b97cea 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -458,17 +458,15 @@ namespace Baobab {
clear_message ();
set_busy (true);
scanner.completed.connect(() => {
+ set_busy (false);
try {
scanner.finish();
} catch (IOError.CANCELLED e) {
// Handle cancellation silently
scanner.clear ();
} catch (Error e) {
- var primary = _("Could not scan folder \"%s\"").printf (scanner.directory.get_parse_name ());
+ var primary = _("Could not scan folder \"%s\" or some of the folders it contains.").printf (scanner.directory.get_parse_name ());
message (primary, e.message, Gtk.MessageType.WARNING);
- scanner.clear ();
- } finally {
- set_busy (false);
}
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]