Skip to content

Commit 551200a

Browse files
刘斌刘斌
authored andcommitted
is cancelled
1 parent d11e4f8 commit 551200a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

library/src/main/java/com/qiniu/android/storage/ResumeUploader.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ private boolean isCancelled() {
192192
}
193193

194194
private void nextTask(final int offset, final int retried, final URI address) {
195+
if (isCancelled()) {
196+
ResponseInfo i = ResponseInfo.cancelled();
197+
completionHandler.complete(key, i, null);
198+
return;
199+
}
200+
195201
if (offset == size) {
196202
CompletionHandler complete = new CompletionHandler() {
197203
@Override
@@ -203,12 +209,6 @@ public void complete(ResponseInfo info, JSONObject response) {
203209
return;
204210
}
205211

206-
if (isCancelled()) {
207-
ResponseInfo i = ResponseInfo.cancelled();
208-
completionHandler.complete(key, i, null);
209-
return;
210-
}
211-
212212
if ((isNotQiniu(info) || info.needRetry()) && retried < config.retryMax) {
213213
nextTask(offset, retried + 1, config.upBackup.address);
214214
return;
@@ -236,11 +236,6 @@ public void onProgress(int bytesWritten, int totalSize) {
236236
@Override
237237
public void complete(ResponseInfo info, JSONObject response) {
238238
if (!info.isOK()) {
239-
if (isCancelled()) {
240-
ResponseInfo i = ResponseInfo.cancelled();
241-
completionHandler.complete(key, i, null);
242-
return;
243-
}
244239
if (info.statusCode == 701 && retried < config.retryMax) {
245240
nextTask((offset / Configuration.BLOCK_SIZE) * Configuration.BLOCK_SIZE, retried + 1, address);
246241
return;
@@ -251,7 +246,7 @@ public void complete(ResponseInfo info, JSONObject response) {
251246
return;
252247
}
253248

254-
completionHandler.complete(key, info, null);
249+
completionHandler.complete(key, info, response);
255250
return;
256251
}
257252
String context = null;

0 commit comments

Comments
 (0)