Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public final class ResponseInfo {
public static final int Cancelled = -2;
public static final int NetworkError = -1;

public static final int Crc32NotMatch = -406;

public static final int UnknownError = 0;

// <-- error code copy from ios
Expand Down Expand Up @@ -171,6 +173,12 @@ private static String getUpType(String path) {
}
}

public static ResponseInfo errorInfo(ResponseInfo old, int statusCode, String error) {
ResponseInfo _new = new ResponseInfo(old.response, statusCode, old.reqId, old.xlog, old.xvia, old.host,
old.path, old.ip, old.port, old.duration, old.sent, error, old.upToken, old.totalSize);
return _new;
}

public static ResponseInfo zeroSize(final UpToken upToken) {
return create(null, ZeroSizeFile, "", "", "", "", "", "", 80, 0, 0, "file or data size is zero", upToken, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,36 @@ public void complete(ResponseInfo info, JSONObject response) {
return;
}
long crc = 0;
Exception tempE = null;
try {
context = response.getString("ctx");
crc = response.getLong("crc32");
} catch (Exception e) {
tempE = e;
e.printStackTrace();
}
if ((context == null || crc != ResumeUploader.this.crc32) && retried < config.retryMax) {
String upHostRetry = config.zone.upHost(token.token, config.useHttps, upHost);
nextTask(offset, retried + 1, upHostRetry);
return;
}
if (context == null) {
String error = "get context failed.";
if (tempE != null) {
error += "\n";
error += tempE.getMessage();
}
ResponseInfo info2 = ResponseInfo.errorInfo(info, ResponseInfo.UnknownError, error);
completionHandler.complete(key, info2, response);
return;
}
if (crc != ResumeUploader.this.crc32) {
String error = "block's crc32 is not match. local: " + ResumeUploader.this.crc32 + ", remote: " + crc;
ResponseInfo info2 = ResponseInfo.errorInfo(info, ResponseInfo.Crc32NotMatch, error);
completionHandler.complete(key, info2, response);
return;
}

contexts[(int) (offset / Configuration.BLOCK_SIZE)] = context;
record(offset + chunkSize);
nextTask(offset + chunkSize, retried, upHost);
Expand Down