Merge lp:~michihenning/storage-framework/add-cancel-on-destroy into lp:storage-framework/devel
- add-cancel-on-destroy
- Merge into devel
Status: | Merged |
---|---|
Approved by: | James Henstridge |
Approved revision: | 67 |
Merged at revision: | 64 |
Proposed branch: | lp:~michihenning/storage-framework/add-cancel-on-destroy |
Merge into: | lp:storage-framework/devel |
Diff against target: |
177 lines (+30/-5) 10 files modified
include/unity/storage/internal/ItemMetadata.h (+1/-0) include/unity/storage/provider/internal/ProviderInterface.h (+1/-0) include/unity/storage/provider/internal/TempfileUploadJobImpl.h (+1/-0) include/unity/storage/qt/client/Exceptions.h (+3/-0) include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h (+3/-0) src/qt/client/internal/local_client/DownloaderImpl.cpp (+3/-0) src/qt/client/internal/local_client/ItemImpl.cpp (+1/-0) src/qt/client/internal/local_client/UploaderImpl.cpp (+4/-0) src/qt/client/internal/remote_client/DownloaderImpl.cpp (+2/-2) src/qt/client/internal/remote_client/UploaderImpl.cpp (+11/-3) |
To merge this branch: | bzr merge lp:~michihenning/storage-framework/add-cancel-on-destroy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
James Henstridge | Approve | ||
Review via email: mp+304025@code.launchpad.net |
Commit message
Send cancel message to server if uploader is destroyed without a prior call to
cancel() or finish_upload().
Description of the change
Send cancel message to server if uploader is destroyed without a prior
call to cancel() or finish_upload().
unity-api-1-bot (unity-api-1-bot) wrote : | # |
- 65. By Michi Henning
-
Suppressed a bunch more compiler warnings from Arm builds.
- 66. By Michi Henning
-
Suppressed one more compiler warning.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:65
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:66
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
I've left an inline comment.
While reading the surrounding code, I think I spotted a bug in UploaderImpl:
Has it really made the code clearer to have these make_ready_
Michi Henning (michihenning) wrote : | # |
Thanks for spotting that bug, it now sets the future via the QFutureInterface.
The QFuture overloads in make_future.h are a little dangerous because it's easy to accidentally return a new future instead of instead of setting the one inside the QFutureInterface.
I'll have a look at cleaning this up in a separate MR.
- 67. By Michi Henning
-
Set future via the promise in the handler rather than returning a new ready future.
James Henstridge (jamesh) wrote : | # |
Looks good!
James Henstridge (jamesh) : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:67
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'include/unity/storage/internal/ItemMetadata.h' |
2 | --- include/unity/storage/internal/ItemMetadata.h 2016-08-11 04:37:13 +0000 |
3 | +++ include/unity/storage/internal/ItemMetadata.h 2016-08-26 02:52:25 +0000 |
4 | @@ -21,6 +21,7 @@ |
5 | #include <unity/storage/common.h> |
6 | |
7 | #pragma GCC diagnostic push |
8 | +#pragma GCC diagnostic ignored "-Wcast-align" |
9 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
10 | #pragma GCC diagnostic ignored "-Wswitch-default" |
11 | #include <QMap> |
12 | |
13 | === modified file 'include/unity/storage/provider/internal/ProviderInterface.h' |
14 | --- include/unity/storage/provider/internal/ProviderInterface.h 2016-08-03 03:55:20 +0000 |
15 | +++ include/unity/storage/provider/internal/ProviderInterface.h 2016-08-26 02:52:25 +0000 |
16 | @@ -22,6 +22,7 @@ |
17 | #include <unity/storage/provider/internal/Handler.h> |
18 | |
19 | #pragma GCC diagnostic push |
20 | +#pragma GCC diagnostic ignored "-Wcast-align" |
21 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
22 | #pragma GCC diagnostic ignored "-Wswitch-default" |
23 | #include <QObject> |
24 | |
25 | === modified file 'include/unity/storage/provider/internal/TempfileUploadJobImpl.h' |
26 | --- include/unity/storage/provider/internal/TempfileUploadJobImpl.h 2016-08-23 09:09:22 +0000 |
27 | +++ include/unity/storage/provider/internal/TempfileUploadJobImpl.h 2016-08-26 02:52:25 +0000 |
28 | @@ -21,6 +21,7 @@ |
29 | #include <unity/storage/provider/internal/UploadJobImpl.h> |
30 | |
31 | #pragma GCC diagnostic push |
32 | +#pragma GCC diagnostic ignored "-Wcast-align" |
33 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
34 | #include <QLocalSocket> |
35 | #include <QTemporaryFile> |
36 | |
37 | === modified file 'include/unity/storage/qt/client/Exceptions.h' |
38 | --- include/unity/storage/qt/client/Exceptions.h 2016-08-05 05:37:23 +0000 |
39 | +++ include/unity/storage/qt/client/Exceptions.h 2016-08-26 02:52:25 +0000 |
40 | @@ -20,7 +20,10 @@ |
41 | |
42 | #include <unity/storage/visibility.h> |
43 | |
44 | +#pragma GCC diagnostic push |
45 | +#pragma GCC diagnostic ignored "-Wcast-align" |
46 | #include <QException> |
47 | +#pragma GCC diagnostic pop |
48 | #include <QString> |
49 | |
50 | namespace unity |
51 | |
52 | === modified file 'include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h' |
53 | --- include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h 2016-08-03 03:20:39 +0000 |
54 | +++ include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h 2016-08-26 02:52:25 +0000 |
55 | @@ -65,12 +65,15 @@ |
56 | std::shared_ptr<ProviderInterface> const& provider); |
57 | |
58 | private: |
59 | + enum State { uploading, finalized }; |
60 | + |
61 | QString upload_id_; |
62 | QDBusUnixFileDescriptor fd_; |
63 | QString old_etag_; |
64 | std::shared_ptr<Root> root_; |
65 | std::shared_ptr<ProviderInterface> provider_; |
66 | std::shared_ptr<QLocalSocket> write_socket_; |
67 | + State state_; |
68 | }; |
69 | |
70 | } // namespace remote_client |
71 | |
72 | === modified file 'src/qt/client/internal/local_client/DownloaderImpl.cpp' |
73 | --- src/qt/client/internal/local_client/DownloaderImpl.cpp 2016-08-11 01:34:55 +0000 |
74 | +++ src/qt/client/internal/local_client/DownloaderImpl.cpp 2016-08-26 02:52:25 +0000 |
75 | @@ -23,7 +23,10 @@ |
76 | #include <unity/storage/qt/client/File.h> |
77 | #include <unity/storage/qt/client/internal/make_future.h> |
78 | |
79 | +#pragma GCC diagnostic push |
80 | +#pragma GCC diagnostic ignored "-Wcast-align" |
81 | #include <QLocalSocket> |
82 | +#pragma GCC diagnostic pop |
83 | |
84 | #include <cassert> |
85 | |
86 | |
87 | === modified file 'src/qt/client/internal/local_client/ItemImpl.cpp' |
88 | --- src/qt/client/internal/local_client/ItemImpl.cpp 2016-08-03 06:09:59 +0000 |
89 | +++ src/qt/client/internal/local_client/ItemImpl.cpp 2016-08-26 02:52:25 +0000 |
90 | @@ -30,6 +30,7 @@ |
91 | |
92 | #include <boost/algorithm/string/predicate.hpp> |
93 | #pragma GCC diagnostic push |
94 | +#pragma GCC diagnostic ignored "-Wcast-align" |
95 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
96 | #include <QtConcurrent> |
97 | #pragma GCC diagnostic pop |
98 | |
99 | === modified file 'src/qt/client/internal/local_client/UploaderImpl.cpp' |
100 | --- src/qt/client/internal/local_client/UploaderImpl.cpp 2016-08-25 05:18:37 +0000 |
101 | +++ src/qt/client/internal/local_client/UploaderImpl.cpp 2016-08-26 02:52:25 +0000 |
102 | @@ -25,7 +25,11 @@ |
103 | #include <unity/storage/qt/client/internal/local_client/tmpfile_prefix.h> |
104 | #include <unity/storage/qt/client/internal/make_future.h> |
105 | |
106 | + |
107 | +#pragma GCC diagnostic push |
108 | +#pragma GCC diagnostic ignored "-Wcast-align" |
109 | #include <QLocalSocket> |
110 | +#pragma GCC diagnostic pop |
111 | |
112 | #include <cassert> |
113 | |
114 | |
115 | === modified file 'src/qt/client/internal/remote_client/DownloaderImpl.cpp' |
116 | --- src/qt/client/internal/remote_client/DownloaderImpl.cpp 2016-08-03 04:13:28 +0000 |
117 | +++ src/qt/client/internal/remote_client/DownloaderImpl.cpp 2016-08-26 02:52:25 +0000 |
118 | @@ -79,9 +79,9 @@ |
119 | { |
120 | auto reply = provider_->FinishDownload(download_id_); |
121 | |
122 | - auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>&) |
123 | + auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf) |
124 | { |
125 | - make_ready_future(); |
126 | + make_ready_future(qf); |
127 | }; |
128 | |
129 | auto handler = new Handler<void>(this, reply, process_reply); |
130 | |
131 | === modified file 'src/qt/client/internal/remote_client/UploaderImpl.cpp' |
132 | --- src/qt/client/internal/remote_client/UploaderImpl.cpp 2016-08-09 02:25:13 +0000 |
133 | +++ src/qt/client/internal/remote_client/UploaderImpl.cpp 2016-08-26 02:52:25 +0000 |
134 | @@ -54,6 +54,7 @@ |
135 | , root_(root.lock()) |
136 | , provider_(provider) |
137 | , write_socket_(new QLocalSocket) |
138 | + , state_(uploading) |
139 | { |
140 | assert(!upload_id.isEmpty()); |
141 | assert(fd.isValid()); |
142 | @@ -66,7 +67,10 @@ |
143 | |
144 | UploaderImpl::~UploaderImpl() |
145 | { |
146 | - write_socket_->abort(); |
147 | + if (state_ == uploading) |
148 | + { |
149 | + provider_->CancelUpload(upload_id_); |
150 | + } |
151 | } |
152 | |
153 | shared_ptr<QLocalSocket> UploaderImpl::socket() const |
154 | @@ -76,6 +80,8 @@ |
155 | |
156 | QFuture<shared_ptr<File>> UploaderImpl::finish_upload() |
157 | { |
158 | + state_ = finalized; |
159 | + |
160 | auto reply = provider_->FinishUpload(upload_id_); |
161 | auto process_reply = [this](decltype(reply) const& reply, QFutureInterface<shared_ptr<File>>& qf) |
162 | { |
163 | @@ -107,10 +113,12 @@ |
164 | |
165 | QFuture<void> UploaderImpl::cancel() noexcept |
166 | { |
167 | + state_ = finalized; |
168 | + |
169 | auto reply = provider_->CancelUpload(upload_id_); |
170 | - auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>&) |
171 | + auto process_reply = [this](decltype(reply) const&, QFutureInterface<void>& qf) |
172 | { |
173 | - make_ready_future(); |
174 | + make_ready_future(qf); |
175 | }; |
176 | |
177 | write_socket_->abort(); |
PASSED: Continuous integration, rev:64 /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/97/ /jenkins. canonical. com/unity- api-1/job/ build/498 /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/504 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= vivid+overlay/ 409 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= xenial+ overlay/ 409 /jenkins. canonical. com/unity- api-1/job/ build-1- sourcepkg/ release= yakkety/ 409 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 339/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 339 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 339/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/97/rebuild
https:/