diff options
author | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-18 19:38:15 +0200 |
---|---|---|
committer | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-30 16:01:22 +0200 |
commit | 155e19a08bddff85de0386c45bac3627a10606bb (patch) | |
tree | 4d3a75834c888890c88506e4621679a8a453c4ce | |
parent | ea496932c37d14c0cf0f1a965d103c8e58f066a5 (diff) | |
download | baobab-155e19a08bddff85de0386c45bac3627a10606bb.tar.gz |
Fix the cancellation logic
The cancellation error was actually never reported because the Results object
carrying it was discarded in cancel_and_reset() when draining the async queue,
so it never had a chance of being processed.
Instead we synthetize a cancellation error ourselves and properly emit the
completed() signal.
-rw-r--r-- | src/baobab-scanner.vala | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala index b3ba68c..7ee5f8e 100644 --- a/src/baobab-scanner.vala +++ b/src/baobab-scanner.vala @@ -373,18 +373,9 @@ namespace Baobab { max_depth = results.max_depth; } - // 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; - } + // Report the first error we encountered + if (results.error != null && scan_error == null) { + scan_error = results.error; } if (results.parent == null) { @@ -454,7 +445,9 @@ namespace Baobab { public void cancel () { if (!successful) { cancel_and_reset (); + scan_error = new IOError.CANCELLED ("Scan was cancelled"); } + completed (); } public void finish () throws Error { |