Skip to content

Commit

Permalink
docs: print logs when etag is not change but the response code isn't …
Browse files Browse the repository at this point in the history
…partial(206)

Refs #589
  • Loading branch information
Jacksgong committed Jun 4, 2017
1 parent 55b055b commit b2ed360
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,20 @@ private void handleFirstConnected(Map<String, List<String>> requestHeader, FileD

// check whether accept partial.
final String newEtag = FileDownloadUtils.findEtag(id, connection);

if (newEtag != null) {
database.updateOldEtagOverdue(model, newEtag);
if (oldEtag.equals(newEtag)) {
FileDownloadLog.w(this, "the old etag[%s] is the same to the new etag[%s], " +
"but the response status code is %d not Partial(206), so wo have to " +
"start this task from very beginning for task[%d]!",
oldEtag, newEtag, code, id);
database.updateOldEtagOverdue(model, null);
} else {
database.updateOldEtagOverdue(model, newEtag);
}
}

// retry to check whether support partial or not.
throw new RetryDirectly();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ public void clear() {
@Override
public void updateOldEtagOverdue(FileDownloadModel model, String newEtag) {
if (model.getETag() == null || model.getETag().equals(newEtag))
throw new IllegalArgumentException();
throw new IllegalArgumentException(FileDownloadUtils
.formatString("old[%s] new[%s]", model.getETag(), newEtag));

model.setSoFar(0);
model.setTotal(0);
Expand Down

0 comments on commit b2ed360

Please sign in to comment.