@@ -105,7 +105,7 @@ private static boolean isNotChunkToQiniu(ResponseInfo info, JSONObject response)
105105 }
106106
107107 public void run () {
108- int offset = recoveryFromRecord ();
108+ long offset = recoveryFromRecord ();
109109 try {
110110 file = new RandomAccessFile (f , "r" );
111111 } catch (FileNotFoundException e ) {
@@ -126,7 +126,7 @@ public void run() {
126126 * @param progress 上传进度
127127 * @param _completionHandler 上传完成处理动作
128128 */
129- private void makeBlock (URI address , int offset , int blockSize , int chunkSize , ProgressHandler progress ,
129+ private void makeBlock (URI address , long offset , int blockSize , int chunkSize , ProgressHandler progress ,
130130 CompletionHandler _completionHandler , UpCancellationSignal c ) {
131131 String path = format (Locale .ENGLISH , "/mkblk/%d" , blockSize );
132132 try {
@@ -141,9 +141,9 @@ private void makeBlock(URI address, int offset, int blockSize, int chunkSize, Pr
141141 post (u , chunkBuffer , 0 , chunkSize , progress , _completionHandler , c );
142142 }
143143
144- private void putChunk (URI address , int offset , int chunkSize , String context , ProgressHandler progress ,
144+ private void putChunk (URI address , long offset , int chunkSize , String context , ProgressHandler progress ,
145145 CompletionHandler _completionHandler , UpCancellationSignal c ) {
146- int chunkOffset = offset % Configuration .BLOCK_SIZE ;
146+ int chunkOffset = ( int ) ( offset % Configuration .BLOCK_SIZE ) ;
147147 String path = format (Locale .ENGLISH , "/bput/%s/%d" , context , chunkOffset );
148148 try {
149149 file .seek (offset );
@@ -195,12 +195,12 @@ private void post(URI uri, byte[] data, int offset, int size, ProgressHandler pr
195195 client .asyncPost (uri .toString (), data , offset , size , headers , progress , completion , c );
196196 }
197197
198- private long calcPutSize (int offset ) {
198+ private long calcPutSize (long offset ) {
199199 long left = size - offset ;
200200 return left < config .chunkSize ? left : config .chunkSize ;
201201 }
202202
203- private long calcBlockSize (int offset ) {
203+ private long calcBlockSize (long offset ) {
204204 long left = size - offset ;
205205 return left < Configuration .BLOCK_SIZE ? left : Configuration .BLOCK_SIZE ;
206206 }
@@ -209,7 +209,7 @@ private boolean isCancelled() {
209209 return options .cancellationSignal .isCancelled ();
210210 }
211211
212- private void nextTask (final int offset , final int retried , final URI address ) {
212+ private void nextTask (final long offset , final int retried , final URI address ) {
213213 if (isCancelled ()) {
214214 ResponseInfo i = ResponseInfo .cancelled ();
215215 completionHandler .complete (key , i , null );
@@ -239,7 +239,7 @@ public void complete(ResponseInfo info, JSONObject response) {
239239 return ;
240240 }
241241
242- final int chunkSize = (int )calcPutSize (offset );
242+ final int chunkSize = (int ) calcPutSize (offset );
243243 ProgressHandler progress = new ProgressHandler () {
244244 @ Override
245245 public void onProgress (int bytesWritten , int totalSize ) {
@@ -279,24 +279,24 @@ public void complete(ResponseInfo info, JSONObject response) {
279279 try {
280280 context = response .getString ("ctx" );
281281 crc = response .getLong ("crc32" );
282- } catch (JSONException e ) {
282+ } catch (Exception e ) {
283283 e .printStackTrace ();
284284 }
285285 if ((context == null || crc != ResumeUploader .this .crc32 ) && retried < config .retryMax ) {
286286 nextTask (offset , retried + 1 , config .upBackup .address );
287287 return ;
288288 }
289- contexts [offset / Configuration .BLOCK_SIZE ] = context ;
289+ contexts [( int ) ( offset / Configuration .BLOCK_SIZE ) ] = context ;
290290 record (offset + chunkSize );
291291 nextTask (offset + chunkSize , retried , address );
292292 }
293293 };
294294 if (offset % Configuration .BLOCK_SIZE == 0 ) {
295- int blockSize = (int )calcBlockSize (offset );
295+ int blockSize = (int ) calcBlockSize (offset );
296296 makeBlock (address , offset , blockSize , chunkSize , progress , complete , options .cancellationSignal );
297297 return ;
298298 }
299- String context = contexts [offset / Configuration .BLOCK_SIZE ];
299+ String context = contexts [( int ) ( offset / Configuration .BLOCK_SIZE ) ];
300300 putChunk (address , offset , chunkSize , context , progress , complete , options .cancellationSignal );
301301 }
302302
@@ -343,7 +343,7 @@ private void removeRecord() {
343343 // "modify_time": lastFileModifyTime,
344344 // "contexts": contexts
345345 //}
346- private void record (int offset ) {
346+ private void record (long offset ) {
347347 if (config .recorder == null || offset == 0 ) {
348348 return ;
349349 }
0 commit comments