Merge lp:~michihenning/storage-framework/remove-qfuture-overloads into lp:storage-framework/devel

Proposed by Michi Henning
Status: Merged
Merged at revision: 66
Proposed branch: lp:~michihenning/storage-framework/remove-qfuture-overloads
Merge into: lp:storage-framework/devel
Diff against target: 705 lines (+131/-92)
13 files modified
include/unity/storage/qt/client/internal/make_future.h (+13/-28)
include/unity/storage/qt/client/internal/remote_client/Handler.h (+8/-4)
src/qt/client/internal/local_client/DownloaderImpl.cpp (+6/-5)
src/qt/client/internal/local_client/UploaderImpl.cpp (+22/-11)
src/qt/client/internal/remote_client/AccountImpl.cpp (+4/-2)
src/qt/client/internal/remote_client/DownloaderImpl.cpp (+1/-1)
src/qt/client/internal/remote_client/FileImpl.cpp (+13/-6)
src/qt/client/internal/remote_client/FolderImpl.cpp (+24/-12)
src/qt/client/internal/remote_client/ItemImpl.cpp (+17/-9)
src/qt/client/internal/remote_client/RootImpl.cpp (+6/-3)
src/qt/client/internal/remote_client/RuntimeImpl.cpp (+10/-5)
src/qt/client/internal/remote_client/UploaderImpl.cpp (+7/-4)
tests/local-client/local-client_test.cpp (+0/-2)
To merge this branch: bzr merge lp:~michihenning/storage-framework/remove-qfuture-overloads
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Needs Fixing
Michi Henning (community) Approve
James Henstridge Approve
Review via email: mp+304042@code.launchpad.net

Commit message

Removed overloads from make_future.h that accept a QFutureInterface because that made it too easy to accidentally call the wrong overload. Added attribute to remaining functions to warn if the return value is unused.

Description of the change

Removed overloads from make_future.h that accept a QFutureInterface because that made it too easy to accidentally call the wrong overload. Added attribute to remaining functions to warn if the return value is unused.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:68
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/101/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/508
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/514
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/419
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/419
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/419
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/349/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/349
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/349/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/101/rebuild

review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Merged manually into devel because Jenkins is sick.

review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/unity/storage/qt/client/internal/make_future.h'
--- include/unity/storage/qt/client/internal/make_future.h 2016-08-02 03:02:15 +0000
+++ include/unity/storage/qt/client/internal/make_future.h 2016-09-06 03:34:37 +0000
@@ -37,7 +37,9 @@
37{37{
3838
39template<typename T>39template<typename T>
40QFuture<T> make_ready_future(T const& val)40QFuture<T>
41__attribute__ ((warn_unused_result))
42make_ready_future(T const& val)
41{43{
42 QFutureInterface<T> qf;44 QFutureInterface<T> qf;
43 qf.reportResult(val);45 qf.reportResult(val);
@@ -45,30 +47,19 @@
45 return qf.future();47 return qf.future();
46}48}
4749
48template<typename T>50template<typename T = void>
49QFuture<T> make_ready_future(QFutureInterface<T> qf, T const& val)51QFuture<T>
50{52__attribute__ ((warn_unused_result))
51 qf.reportResult(val);53make_ready_future()
52 qf.reportFinished();
53 return qf.future();
54}
55
56template<typename T = void>
57QFuture<T> make_ready_future(QFutureInterface<T> qf)
58{
59 qf.reportFinished();
60 return qf.future();
61}
62
63template<typename T = void>
64QFuture<T> make_ready_future()
65{54{
66 QFutureInterface<void> qf;55 QFutureInterface<void> qf;
67 return make_ready_future(qf);56 return make_ready_future(qf);
68}57}
6958
70template<typename E>59template<typename E>
71QFuture<void> make_exceptional_future(E const& ex)60QFuture<void>
61__attribute__
62((warn_unused_result)) make_exceptional_future(E const& ex)
72{63{
73 QFutureInterface<void> qf;64 QFutureInterface<void> qf;
74 qf.reportException(ex);65 qf.reportException(ex);
@@ -77,7 +68,9 @@
77}68}
7869
79template<typename T, typename E>70template<typename T, typename E>
80QFuture<T> make_exceptional_future(E const& ex)71QFuture<T>
72__attribute__ ((warn_unused_result))
73make_exceptional_future(E const& ex)
81{74{
82 QFutureInterface<T> qf;75 QFutureInterface<T> qf;
83 qf.reportException(ex);76 qf.reportException(ex);
@@ -85,14 +78,6 @@
85 return qf.future();78 return qf.future();
86}79}
8780
88template<typename T, typename E>
89QFuture<T> make_exceptional_future(QFutureInterface<T> qf, E const& ex)
90{
91 qf.reportException(ex);
92 qf.reportFinished();
93 return qf.future();
94}
95
96} // namespace internal81} // namespace internal
97} // namespace client82} // namespace client
98} // namespace qt83} // namespace qt
9984
=== modified file 'include/unity/storage/qt/client/internal/remote_client/Handler.h'
--- include/unity/storage/qt/client/internal/remote_client/Handler.h 2016-08-17 02:55:12 +0000
+++ include/unity/storage/qt/client/internal/remote_client/Handler.h 2016-09-06 03:34:37 +0000
@@ -84,21 +84,25 @@
84 catch (LocalCommsException const& e)84 catch (LocalCommsException const& e)
85 {85 {
86 qCritical() << "provider exception:" << e.what();86 qCritical() << "provider exception:" << e.what();
87 make_exceptional_future<T>(qf_, e);87 qf_.reportException(e);
88 qf_.reportFinished();
88 }89 }
89 catch (RemoteCommsException const& e)90 catch (RemoteCommsException const& e)
90 {91 {
91 qCritical() << "provider exception:" << e.what();92 qCritical() << "provider exception:" << e.what();
92 make_exceptional_future<T>(qf_, e);93 qf_.reportException(e);
94 qf_.reportFinished();
93 }95 }
94 catch (ResourceException const& e)96 catch (ResourceException const& e)
95 {97 {
96 qCritical() << "provider exception:" << e.what();98 qCritical() << "provider exception:" << e.what();
97 make_exceptional_future<T>(qf_, e);99 qf_.reportException(e);
100 qf_.reportFinished();
98 }101 }
99 catch (StorageException const& e)102 catch (StorageException const& e)
100 {103 {
101 make_exceptional_future<T>(qf_, e);104 qf_.reportException(e);
105 qf_.reportFinished();
102 }106 }
103 // LCOV_EXCL_START107 // LCOV_EXCL_START
104 catch (...)108 catch (...)
105109
=== modified file 'src/qt/client/internal/local_client/DownloaderImpl.cpp'
--- src/qt/client/internal/local_client/DownloaderImpl.cpp 2016-09-01 03:09:40 +0000
+++ src/qt/client/internal/local_client/DownloaderImpl.cpp 2016-09-06 03:34:37 +0000
@@ -121,7 +121,7 @@
121 + QString::number(written) + " byte";121 + QString::number(written) + " byte";
122 msg += written == 1 ? " was" : "s were";122 msg += written == 1 ? " was" : "s were";
123 msg += " consumed.";123 msg += " consumed.";
124 make_exceptional_future(qf_, LogicException(msg));124 qf_.reportException(LogicException(msg));
125 }125 }
126 else126 else
127 {127 {
@@ -136,12 +136,12 @@
136 case cancelled:136 case cancelled:
137 {137 {
138 QString msg = "Downloader::finish_download(): download of " + filename_ + " was cancelled";138 QString msg = "Downloader::finish_download(): download of " + filename_ + " was cancelled";
139 make_exceptional_future(qf_, CancelledException(msg));139 qf_.reportException(CancelledException(msg));
140 break;140 break;
141 }141 }
142 case error:142 case error:
143 {143 {
144 make_exceptional_future(qf_, ResourceException(error_msg_, error_code_));144 qf_.reportException(ResourceException(error_msg_, error_code_));
145 break;145 break;
146 }146 }
147 default:147 default:
@@ -149,7 +149,7 @@
149 abort(); // LCOV_EXCL_LINE // Impossible149 abort(); // LCOV_EXCL_LINE // Impossible
150 }150 }
151 }151 }
152 make_ready_future(qf_);152 qf_.reportFinished();
153 QThread::currentThread()->quit();153 QThread::currentThread()->quit();
154}154}
155155
@@ -268,7 +268,8 @@
268 // LCOV_EXCL_START268 // LCOV_EXCL_START
269 QString msg = "Downloader: cannot create socket pair: "269 QString msg = "Downloader: cannot create socket pair: "
270 + QString::fromStdString(storage::internal::safe_strerror(errno));270 + QString::fromStdString(storage::internal::safe_strerror(errno));
271 make_exceptional_future(qf_, ResourceException(msg, errno));271 qf_.reportException(ResourceException(msg, errno));
272 qf_.reportFinished();
272 return;273 return;
273 // LCOV_EXCL_STOP274 // LCOV_EXCL_STOP
274 }275 }
275276
=== modified file 'src/qt/client/internal/local_client/UploaderImpl.cpp'
--- src/qt/client/internal/local_client/UploaderImpl.cpp 2016-09-01 03:09:40 +0000
+++ src/qt/client/internal/local_client/UploaderImpl.cpp 2016-09-06 03:34:37 +0000
@@ -151,7 +151,8 @@
151 {151 {
152 QString msg = "Uploader::finish_upload(): " + path_ + ": upload size of " + QString::number(size_)152 QString msg = "Uploader::finish_upload(): " + path_ + ": upload size of " + QString::number(size_)
153 + " does not match actual number of bytes read: " + QString::number(bytes_read_);153 + " does not match actual number of bytes read: " + QString::number(bytes_read_);
154 make_exceptional_future(qf_, LogicException(msg));154 qf_.reportException(LogicException(msg));
155 qf_.reportFinished();
155 }156 }
156 else157 else
157 {158 {
@@ -167,13 +168,15 @@
167 case cancelled:168 case cancelled:
168 {169 {
169 QString msg = "Uploader::finish_upload(): upload was cancelled";170 QString msg = "Uploader::finish_upload(): upload was cancelled";
170 make_exceptional_future(qf_, CancelledException(msg));171 qf_.reportException(CancelledException(msg));
172 qf_.reportFinished();
171 break;173 break;
172 }174 }
173 case error:175 case error:
174 {176 {
175 // LCOV_EXCL_START177 // LCOV_EXCL_START
176 make_exceptional_future(qf_, ResourceException(error_msg_, error_code_));178 qf_.reportException(ResourceException(error_msg_, error_code_));
179 qf_.reportFinished();
177 break;180 break;
178 // LCOV_EXCL_STOP181 // LCOV_EXCL_STOP
179 }182 }
@@ -241,7 +244,8 @@
241 if (impl->has_conflict())244 if (impl->has_conflict())
242 {245 {
243 state_ = error;246 state_ = error;
244 make_exceptional_future(qf_, ConflictException("Uploader::finish_upload(): ETag mismatch"));247 qf_.reportException(ConflictException("Uploader::finish_upload(): ETag mismatch"));
248 qf_.reportFinished();
245 return;249 return;
246 }250 }
247 }251 }
@@ -254,7 +258,8 @@
254 state_ = error;258 state_ = error;
255 QString msg = "Uploader::finish_upload(): item with name \"" + path_ + "\" exists already";259 QString msg = "Uploader::finish_upload(): item with name \"" + path_ + "\" exists already";
256 QString name = QString::fromStdString(boost::filesystem::path(path_.toStdString()).filename().native());260 QString name = QString::fromStdString(boost::filesystem::path(path_.toStdString()).filename().native());
257 make_exceptional_future(qf_, ExistsException(msg, path_, name));261 qf_.reportException(ExistsException(msg, path_, name));
262 qf_.reportFinished();
258 return;263 return;
259 }264 }
260 if (close(fd) == -1)265 if (close(fd) == -1)
@@ -263,7 +268,8 @@
263 state_ = error;268 state_ = error;
264 QString msg = "Uploader::finish_upload(): cannot close tmp file: "269 QString msg = "Uploader::finish_upload(): cannot close tmp file: "
265 + QString::fromStdString(storage::internal::safe_strerror(errno));270 + QString::fromStdString(storage::internal::safe_strerror(errno));
266 make_exceptional_future(qf_, ResourceException(msg, errno));271 qf_.reportException(ResourceException(msg, errno));
272 qf_.reportFinished();
267 return;273 return;
268 // LCOV_EXCL_STOP274 // LCOV_EXCL_STOP
269 }275 }
@@ -277,7 +283,8 @@
277 // LCOV_EXCL_START283 // LCOV_EXCL_START
278 state_ = error;284 state_ = error;
279 QString msg = "Uploader::finish_upload(): cannot flush output file: " + output_file_->errorString();285 QString msg = "Uploader::finish_upload(): cannot flush output file: " + output_file_->errorString();
280 make_exceptional_future(qf_, ResourceException(msg, output_file_->error()));286 qf_.reportException(ResourceException(msg, output_file_->error()));
287 qf_.reportFinished();
281 return;288 return;
282 // LCOV_EXCL_STOP289 // LCOV_EXCL_STOP
283 }290 }
@@ -296,7 +303,8 @@
296 QString msg = "Uploader::finish_upload(): linkat \"" + QString::fromStdString(old_path)303 QString msg = "Uploader::finish_upload(): linkat \"" + QString::fromStdString(old_path)
297 + "\" to \"" + file->native_identity() + "\" failed: "304 + "\" to \"" + file->native_identity() + "\" failed: "
298 + QString::fromStdString(storage::internal::safe_strerror(errno));305 + QString::fromStdString(storage::internal::safe_strerror(errno));
299 make_exceptional_future(qf_, ResourceException(msg, error_code));306 qf_.reportException(ResourceException(msg, error_code));
307 qf_.reportFinished();
300 return;308 return;
301 // LCOV_EXCL_STOP309 // LCOV_EXCL_STOP
302 }310 }
@@ -312,7 +320,8 @@
312 QString msg = "Uploader::finish_upload(): rename \"" + QString::fromStdString(old_path)320 QString msg = "Uploader::finish_upload(): rename \"" + QString::fromStdString(old_path)
313 + "\" to \"" + file->native_identity() + "\" failed: "321 + "\" to \"" + file->native_identity() + "\" failed: "
314 + QString::fromStdString(storage::internal::safe_strerror(errno));322 + QString::fromStdString(storage::internal::safe_strerror(errno));
315 make_exceptional_future(qf_, ResourceException(msg, error_code));323 qf_.reportException(ResourceException(msg, error_code));
324 qf_.reportFinished();
316 return;325 return;
317 }326 }
318 // LCOV_EXCL_STOP327 // LCOV_EXCL_STOP
@@ -321,7 +330,8 @@
321 state_ = finalized;330 state_ = finalized;
322 output_file_->close();331 output_file_->close();
323 impl->set_timestamps();332 impl->set_timestamps();
324 make_ready_future(qf_, file);333 qf_.reportResult(file);
334 qf_.reportFinished();
325}335}
326336
327// LCOV_EXCL_START337// LCOV_EXCL_START
@@ -366,7 +376,8 @@
366 // LCOV_EXCL_START376 // LCOV_EXCL_START
367 QString msg = "Uploader: cannot create socket pair: "377 QString msg = "Uploader: cannot create socket pair: "
368 + QString::fromStdString(storage::internal::safe_strerror(errno));378 + QString::fromStdString(storage::internal::safe_strerror(errno));
369 make_exceptional_future(qf_, ResourceException(msg, errno));379 qf_.reportException(ResourceException(msg, errno));
380 qf_.reportFinished();
370 return;381 return;
371 // LCOV_EXCL_STOP382 // LCOV_EXCL_STOP
372 }383 }
373384
=== modified file 'src/qt/client/internal/remote_client/AccountImpl.cpp'
--- src/qt/client/internal/remote_client/AccountImpl.cpp 2016-08-22 04:56:44 +0000
+++ src/qt/client/internal/remote_client/AccountImpl.cpp 2016-09-06 03:34:37 +0000
@@ -96,7 +96,8 @@
96 }96 }
97 catch (RuntimeDestroyedException const& e)97 catch (RuntimeDestroyedException const& e)
98 {98 {
99 make_exceptional_future(qf, RuntimeDestroyedException("Account::roots()"));99 qf.reportException(RuntimeDestroyedException("Account::roots()"));
100 qf.reportFinished();
100 return;101 return;
101 }102 }
102103
@@ -113,7 +114,8 @@
113 roots.append(root);114 roots.append(root);
114 }115 }
115 roots_ = roots;116 roots_ = roots;
116 make_ready_future(qf, roots);117 qf.reportResult(roots);
118 qf.reportFinished();
117 };119 };
118120
119 auto handler = new Handler<QVector<Root::SPtr>>(this, reply, process_reply);121 auto handler = new Handler<QVector<Root::SPtr>>(this, reply, process_reply);
120122
=== modified file 'src/qt/client/internal/remote_client/DownloaderImpl.cpp'
--- src/qt/client/internal/remote_client/DownloaderImpl.cpp 2016-09-01 03:09:40 +0000
+++ src/qt/client/internal/remote_client/DownloaderImpl.cpp 2016-09-06 03:34:37 +0000
@@ -81,7 +81,7 @@
8181
82 auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf)82 auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf)
83 {83 {
84 make_ready_future(qf);84 qf.reportFinished();
85 };85 };
8686
87 auto handler = new Handler<void>(this, reply, process_reply);87 auto handler = new Handler<void>(this, reply, process_reply);
8888
=== modified file 'src/qt/client/internal/remote_client/FileImpl.cpp'
--- src/qt/client/internal/remote_client/FileImpl.cpp 2016-08-11 07:06:35 +0000
+++ src/qt/client/internal/remote_client/FileImpl.cpp 2016-09-06 03:34:37 +0000
@@ -80,7 +80,8 @@
80 auto root = get_root();80 auto root = get_root();
81 if (!root)81 if (!root)
82 {82 {
83 make_exceptional_future(qf, RuntimeDestroyedException("File::create_uploader()"));83 qf.reportException(RuntimeDestroyedException("File::create_uploader()"));
84 qf.reportFinished();
84 return;85 return;
85 }86 }
8687
@@ -91,11 +92,13 @@
91 // TODO: log server error here92 // TODO: log server error here
92 QString msg = "File::create_uploader(): impossible file descriptor returned by server: "93 QString msg = "File::create_uploader(): impossible file descriptor returned by server: "
93 + QString::number(fd.fileDescriptor());94 + QString::number(fd.fileDescriptor());
94 make_exceptional_future(qf, LocalCommsException(msg));95 qf.reportException(LocalCommsException(msg));
96 qf.reportFinished();
95 return;97 return;
96 }98 }
97 auto uploader = UploaderImpl::make_uploader(upload_id, fd, size, old_etag, root, prov);99 auto uploader = UploaderImpl::make_uploader(upload_id, fd, size, old_etag, root, prov);
98 make_ready_future(qf, uploader);100 qf.reportResult(uploader);
101 qf.reportFinished();
99 };102 };
100 auto handler = new Handler<shared_ptr<Uploader>>(this, reply, process_reply);103 auto handler = new Handler<shared_ptr<Uploader>>(this, reply, process_reply);
101 return handler->future();104 return handler->future();
@@ -124,7 +127,9 @@
124 }127 }
125 catch (StorageException const& e)128 catch (StorageException const& e)
126 {129 {
127 make_exceptional_future(qf, e);130 qf.reportException(e);
131 qf.reportFinished();
132 return;
128 }133 }
129134
130 auto download_id = reply.argumentAt<0>();135 auto download_id = reply.argumentAt<0>();
@@ -134,13 +139,15 @@
134 // TODO: log server error here139 // TODO: log server error here
135 QString msg = "File::create_downloader(): impossible file descriptor returned by server: "140 QString msg = "File::create_downloader(): impossible file descriptor returned by server: "
136 + QString::number(fd.fileDescriptor());141 + QString::number(fd.fileDescriptor());
137 make_exceptional_future(qf, LocalCommsException(msg));142 qf.reportException(LocalCommsException(msg));
143 qf.reportFinished();
138 return;144 return;
139 }145 }
140 auto file = dynamic_pointer_cast<File>(public_instance_.lock());146 auto file = dynamic_pointer_cast<File>(public_instance_.lock());
141 // TODO: provider may not be around anymore if the runtime was destroyed.147 // TODO: provider may not be around anymore if the runtime was destroyed.
142 auto downloader = DownloaderImpl::make_downloader(download_id, fd, file, prov);148 auto downloader = DownloaderImpl::make_downloader(download_id, fd, file, prov);
143 make_ready_future(qf, downloader);149 qf.reportResult(downloader);
150 qf.reportFinished();
144 };151 };
145152
146 auto handler = new Handler<shared_ptr<Downloader>>(this, reply, process_reply);153 auto handler = new Handler<shared_ptr<Downloader>>(this, reply, process_reply);
147154
=== modified file 'src/qt/client/internal/remote_client/FolderImpl.cpp'
--- src/qt/client/internal/remote_client/FolderImpl.cpp 2016-08-09 02:25:13 +0000
+++ src/qt/client/internal/remote_client/FolderImpl.cpp 2016-09-06 03:34:37 +0000
@@ -78,7 +78,8 @@
78 auto root = get_root();78 auto root = get_root();
79 if (!root)79 if (!root)
80 {80 {
81 make_exceptional_future(qf, RuntimeDestroyedException("Folder::list()"));81 qf.reportException(RuntimeDestroyedException("Folder::list()"));
82 qf.reportFinished();
82 return;83 return;
83 }84 }
8485
@@ -92,7 +93,8 @@
92 }93 }
93 catch (StorageException const& e)94 catch (StorageException const& e)
94 {95 {
95 make_exceptional_future(qf, e);96 qf.reportException(e);
97 qf.reportFinished();
96 return;98 return;
97 }99 }
98 if (md.type == ItemType::root)100 if (md.type == ItemType::root)
@@ -140,7 +142,8 @@
140 auto root = get_root();142 auto root = get_root();
141 if (!root)143 if (!root)
142 {144 {
143 make_exceptional_future(qf, RuntimeDestroyedException("Folder::lookup()"));145 qf.reportException(RuntimeDestroyedException("Folder::lookup()"));
146 qf.reportFinished();
144 return;147 return;
145 }148 }
146149
@@ -154,7 +157,8 @@
154 }157 }
155 catch (StorageException const& e)158 catch (StorageException const& e)
156 {159 {
157 make_exceptional_future(qf, e);160 qf.reportException(e);
161 qf.reportFinished();
158 return;162 return;
159 }163 }
160 if (md.type == ItemType::root)164 if (md.type == ItemType::root)
@@ -166,10 +170,12 @@
166 }170 }
167 if (items.isEmpty())171 if (items.isEmpty())
168 {172 {
169 make_exceptional_future(qf, NotExistsException("Folder::lookup(): no such item: " + name, name));173 qf.reportException(NotExistsException("Folder::lookup(): no such item: " + name, name));
174 qf.reportFinished();
170 return;175 return;
171 }176 }
172 make_ready_future(qf, items);177 qf.reportResult(items);
178 qf.reportFinished();
173 };179 };
174180
175 auto handler = new Handler<QVector<shared_ptr<Item>>>(const_cast<FolderImpl*>(this), reply, process_reply);181 auto handler = new Handler<QVector<shared_ptr<Item>>>(const_cast<FolderImpl*>(this), reply, process_reply);
@@ -195,7 +201,8 @@
195 auto root = get_root();201 auto root = get_root();
196 if (!root)202 if (!root)
197 {203 {
198 make_exceptional_future(qf, RuntimeDestroyedException("Folder::create_folder()"));204 qf.reportException(RuntimeDestroyedException("Folder::create_folder()"));
205 qf.reportFinished();
199 return;206 return;
200 }207 }
201208
@@ -207,7 +214,8 @@
207 }214 }
208 catch (StorageException const& e)215 catch (StorageException const& e)
209 {216 {
210 make_exceptional_future(qf, e);217 qf.reportException(e);
218 qf.reportFinished();
211 return;219 return;
212 }220 }
213 if (md.type != ItemType::folder)221 if (md.type != ItemType::folder)
@@ -215,10 +223,12 @@
215 // TODO: log server error here223 // TODO: log server error here
216 QString msg = "File::create_folder(): impossible item type returned by server: "224 QString msg = "File::create_folder(): impossible item type returned by server: "
217 + QString::number(int(md.type));225 + QString::number(int(md.type));
218 make_exceptional_future(qf, LocalCommsException(msg));226 qf.reportException(LocalCommsException(msg));
227 qf.reportFinished();
219 return;228 return;
220 }229 }
221 make_ready_future(qf, FolderImpl::make_folder(md, root));230 qf.reportResult(FolderImpl::make_folder(md, root));
231 qf.reportFinished();
222 };232 };
223233
224 auto handler = new Handler<shared_ptr<Folder>>(this, reply, process_reply);234 auto handler = new Handler<shared_ptr<Folder>>(this, reply, process_reply);
@@ -249,14 +259,16 @@
249 auto root = get_root();259 auto root = get_root();
250 if (!root)260 if (!root)
251 {261 {
252 make_exceptional_future(qf, RuntimeDestroyedException("Folder::create_file()"));262 qf.reportException(RuntimeDestroyedException("Folder::create_file()"));
263 qf.reportFinished();
253 return;264 return;
254 }265 }
255266
256 auto upload_id = reply.argumentAt<0>();267 auto upload_id = reply.argumentAt<0>();
257 auto fd = reply.argumentAt<1>();268 auto fd = reply.argumentAt<1>();
258 auto uploader = UploaderImpl::make_uploader(upload_id, fd, size, "", root, provider());269 auto uploader = UploaderImpl::make_uploader(upload_id, fd, size, "", root, provider());
259 make_ready_future(qf, uploader);270 qf.reportResult(uploader);
271 qf.reportFinished();
260 };272 };
261273
262 auto handler = new Handler<shared_ptr<Uploader>>(this, reply, process_reply);274 auto handler = new Handler<shared_ptr<Uploader>>(this, reply, process_reply);
263275
=== modified file 'src/qt/client/internal/remote_client/ItemImpl.cpp'
--- src/qt/client/internal/remote_client/ItemImpl.cpp 2016-08-09 07:04:11 +0000
+++ src/qt/client/internal/remote_client/ItemImpl.cpp 2016-09-06 03:34:37 +0000
@@ -102,7 +102,8 @@
102 auto root = get_root();102 auto root = get_root();
103 if (!root)103 if (!root)
104 {104 {
105 make_exceptional_future(qf, RuntimeDestroyedException("Item::copy()"));105 qf.reportException(RuntimeDestroyedException("Item::copy()"));
106 qf.reportFinished();
106 return;107 return;
107 }108 }
108109
@@ -113,7 +114,8 @@
113 }114 }
114 catch (StorageException const& e)115 catch (StorageException const& e)
115 {116 {
116 make_exceptional_future(qf, e);117 qf.reportException(e);
118 qf.reportFinished();
117 return;119 return;
118 }120 }
119 if (md.type == ItemType::root)121 if (md.type == ItemType::root)
@@ -121,10 +123,12 @@
121 // TODO: log server error here123 // TODO: log server error here
122 QString msg = "File::create_folder(): impossible item type returned by server: "124 QString msg = "File::create_folder(): impossible item type returned by server: "
123 + QString::number(int(md.type));125 + QString::number(int(md.type));
124 make_exceptional_future(qf, LocalCommsException(msg));126 qf.reportException(LocalCommsException(msg));
127 qf.reportFinished();
125 return;128 return;
126 }129 }
127 make_ready_future(qf, ItemImpl::make_item(md, root));130 qf.reportResult(ItemImpl::make_item(md, root));
131 qf.reportFinished();
128 return;132 return;
129 };133 };
130134
@@ -163,7 +167,8 @@
163 auto root = get_root();167 auto root = get_root();
164 if (!root)168 if (!root)
165 {169 {
166 make_exceptional_future(qf, RuntimeDestroyedException("Item::move()"));170 qf.reportException(RuntimeDestroyedException("Item::move()"));
171 qf.reportFinished();
167 return;172 return;
168 }173 }
169174
@@ -174,17 +179,20 @@
174 }179 }
175 catch (StorageException const& e)180 catch (StorageException const& e)
176 {181 {
177 make_exceptional_future(qf, e);182 qf.reportException(e);
183 qf.reportFinished();
178 return;184 return;
179 }185 }
180 if (md.type == ItemType::root)186 if (md.type == ItemType::root)
181 {187 {
182 // TODO: log server error here188 // TODO: log server error here
183 QString msg = "Item::move(): impossible root item returned by server";189 QString msg = "Item::move(): impossible root item returned by server";
184 make_exceptional_future(qf, LocalCommsException(msg));190 qf.reportException(LocalCommsException(msg));
191 qf.reportFinished();
185 return;192 return;
186 }193 }
187 make_ready_future(qf, ItemImpl::make_item(md, root));194 qf.reportResult(ItemImpl::make_item(md, root));
195 qf.reportFinished();
188 };196 };
189197
190 auto handler = new Handler<shared_ptr<Item>>(this, reply, process_reply);198 auto handler = new Handler<shared_ptr<Item>>(this, reply, process_reply);
@@ -229,7 +237,7 @@
229 auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf)237 auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf)
230 {238 {
231 deleted_ = true;239 deleted_ = true;
232 make_ready_future(qf);240 qf.reportFinished();
233 };241 };
234242
235 auto handler = new Handler<void>(this, reply, process_reply);243 auto handler = new Handler<void>(this, reply, process_reply);
236244
=== modified file 'src/qt/client/internal/remote_client/RootImpl.cpp'
--- src/qt/client/internal/remote_client/RootImpl.cpp 2016-08-09 02:25:13 +0000
+++ src/qt/client/internal/remote_client/RootImpl.cpp 2016-09-06 03:34:37 +0000
@@ -133,7 +133,8 @@
133 }133 }
134 catch (RuntimeDestroyedException const&)134 catch (RuntimeDestroyedException const&)
135 {135 {
136 make_exceptional_future(qf, RuntimeDestroyedException("Root::get()"));136 qf.reportException(RuntimeDestroyedException("Root::get()"));
137 qf.reportFinished();
137 return;138 return;
138 }139 }
139140
@@ -144,7 +145,8 @@
144 }145 }
145 catch (StorageException const& e)146 catch (StorageException const& e)
146 {147 {
147 make_exceptional_future(qf, e);148 qf.reportException(e);
149 qf.reportFinished();
148 return;150 return;
149 }151 }
150 Item::SPtr item;152 Item::SPtr item;
@@ -157,7 +159,8 @@
157 // acc owns the root, so the root weak_ptr is guaranteed to be lockable.159 // acc owns the root, so the root weak_ptr is guaranteed to be lockable.
158 item = ItemImpl::make_item(md, root_);160 item = ItemImpl::make_item(md, root_);
159 }161 }
160 make_ready_future(qf, item);162 qf.reportResult(item);
163 qf.reportFinished();
161 };164 };
162165
163 auto handler = new Handler<Item::SPtr>(const_cast<RootImpl*>(this), reply, process_reply);166 auto handler = new Handler<Item::SPtr>(const_cast<RootImpl*>(this), reply, process_reply);
164167
=== modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp'
--- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-08-19 06:18:54 +0000
+++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-09-06 03:34:37 +0000
@@ -105,7 +105,9 @@
105{105{
106 if (destroyed_)106 if (destroyed_)
107 {107 {
108 return make_exceptional_future(qf_, RuntimeDestroyedException("Runtime::accounts()"));108 qf_.reportException(RuntimeDestroyedException("Runtime::accounts()"));
109 qf_.reportFinished();
110 return qf_.future();
109 }111 }
110112
111 if (!manager_)113 if (!manager_)
@@ -131,7 +133,8 @@
131 if (destroyed_)133 if (destroyed_)
132 {134 {
133 // LCOV_EXCL_START135 // LCOV_EXCL_START
134 make_exceptional_future(qf_, RuntimeDestroyedException("Runtime::accounts()"));136 qf_.reportException(RuntimeDestroyedException("Runtime::accounts()"));
137 qf_.reportFinished();
135 return;138 return;
136 // LCOV_EXCL_STOP139 // LCOV_EXCL_STOP
137 }140 }
@@ -161,20 +164,22 @@
161 }164 }
162 }165 }
163 accounts_ = accounts;166 accounts_ = accounts;
164 make_ready_future(qf_, accounts);167 qf_.reportResult(accounts);
165 }168 }
166 // LCOV_EXCL_START169 // LCOV_EXCL_START
167 catch (StorageException const& e)170 catch (StorageException const& e)
168 {171 {
169 make_exceptional_future(qf_, e);172 qf_.reportException(e);
170 }173 }
171 // LCOV_EXCL_STOP174 // LCOV_EXCL_STOP
175 qf_.reportFinished();
172}176}
173177
174// LCOV_EXCL_START178// LCOV_EXCL_START
175void RuntimeImpl::timeout()179void RuntimeImpl::timeout()
176{180{
177 make_exceptional_future(qf_, ResourceException("Runtime::accounts(): timeout retrieving Online accounts", 0));181 qf_.reportException(ResourceException("Runtime::accounts(): timeout retrieving Online accounts", 0));
182 qf_.reportFinished();
178}183}
179// LCOV_EXCL_STOP184// LCOV_EXCL_STOP
180185
181186
=== modified file 'src/qt/client/internal/remote_client/UploaderImpl.cpp'
--- src/qt/client/internal/remote_client/UploaderImpl.cpp 2016-09-01 03:09:40 +0000
+++ src/qt/client/internal/remote_client/UploaderImpl.cpp 2016-09-06 03:34:37 +0000
@@ -92,7 +92,8 @@
92 }92 }
93 catch (StorageException const& e)93 catch (StorageException const& e)
94 {94 {
95 make_exceptional_future(qf, e);95 qf.reportException(e);
96 qf.reportFinished();
96 return;97 return;
97 }98 }
98 if (md.type != ItemType::file)99 if (md.type != ItemType::file)
@@ -100,10 +101,12 @@
100 // TODO: log server error here101 // TODO: log server error here
101 QString msg = "Uploader::finish_upload(): impossible item type returned by server: "102 QString msg = "Uploader::finish_upload(): impossible item type returned by server: "
102 + QString::number(int(md.type));103 + QString::number(int(md.type));
103 make_exceptional_future(qf, LocalCommsException(msg));104 qf.reportException(LocalCommsException(msg));
105 qf.reportFinished();
104 return;106 return;
105 }107 }
106 make_ready_future(qf, FileImpl::make_file(md, root_));108 qf.reportResult(FileImpl::make_file(md, root_));
109 qf.reportFinished();
107 };110 };
108111
109 write_socket_->disconnectFromServer();112 write_socket_->disconnectFromServer();
@@ -118,7 +121,7 @@
118 auto reply = provider_->CancelUpload(upload_id_);121 auto reply = provider_->CancelUpload(upload_id_);
119 auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf)122 auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf)
120 {123 {
121 make_ready_future(qf);124 qf.reportFinished();
122 };125 };
123126
124 write_socket_->abort();127 write_socket_->abort();
125128
=== modified file 'tests/local-client/local-client_test.cpp'
--- tests/local-client/local-client_test.cpp 2016-08-25 04:05:18 +0000
+++ tests/local-client/local-client_test.cpp 2016-09-06 03:34:37 +0000
@@ -425,7 +425,6 @@
425 EXPECT_EQ(0, file->size());425 EXPECT_EQ(0, file->size());
426 auto old_etag = file->etag();426 auto old_etag = file->etag();
427427
428 qDebug() << "Uploading 0 bytes";
429 // Create uploader for the file and write nothing.428 // Create uploader for the file and write nothing.
430 uploader = call(file->create_uploader(ConflictPolicy::overwrite, 0));429 uploader = call(file->create_uploader(ConflictPolicy::overwrite, 0));
431 file = call(uploader->finish_upload());430 file = call(uploader->finish_upload());
@@ -436,7 +435,6 @@
436 uploader = call(file->create_uploader(ConflictPolicy::overwrite, s.size()));435 uploader = call(file->create_uploader(ConflictPolicy::overwrite, s.size()));
437 EXPECT_EQ(1000000, uploader->size());436 EXPECT_EQ(1000000, uploader->size());
438 uploader->socket()->write(&s[0], s.size());437 uploader->socket()->write(&s[0], s.size());
439 qDebug() << "Waiting for write to complete";
440 uploader->socket()->waitForBytesWritten(SIGNAL_WAIT_TIME);438 uploader->socket()->waitForBytesWritten(SIGNAL_WAIT_TIME);
441439
442 // Need to sleep here, otherwise it is possible for the440 // Need to sleep here, otherwise it is possible for the

Subscribers

People subscribed via source and target branches

to all changes: