[gnote] Cancel upload on failure
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Cancel upload on failure
- Date: Sat, 2 May 2020 19:10:33 +0000 (UTC)
commit d9ba1d9a2362d90f3526f51e01007cab649a443d
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat May 2 22:07:24 2020 +0300
Cancel upload on failure
src/synchronization/filesystemsyncserver.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/synchronization/filesystemsyncserver.cpp b/src/synchronization/filesystemsyncserver.cpp
index 63a66422..95d6c0cd 100644
--- a/src/synchronization/filesystemsyncserver.cpp
+++ b/src/synchronization/filesystemsyncserver.cpp
@@ -95,6 +95,7 @@ void FileSystemSyncServer::upload_notes(const std::vector<Note::Ptr> & notes)
m_updated_notes.reserve(notes.size());
Glib::Mutex notes_lock;
Glib::Cond all_uploaded;
+ auto cancel_op = Gio::Cancellable::create();
unsigned failures = 0;
unsigned total = notes.size();
for(auto & iter : notes) {
@@ -121,16 +122,18 @@ void FileSystemSyncServer::upload_notes(const std::vector<Note::Ptr> & notes)
notes_lock.lock();
++failures;
- if(--total == 0) {
- all_uploaded.signal();
- }
+ --total;
+ all_uploaded.signal();
notes_lock.unlock();
- });
+ }, cancel_op);
}
notes_lock.lock();
while(total > 0) {
all_uploaded.wait(notes_lock);
+ if(failures > 0) {
+ cancel_op->cancel();
+ }
}
notes_lock.unlock();
if(failures > 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]