@@ -108,7 +108,7 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
108
108
{
109
109
long uploadedBytes = 0 ;
110
110
long fileSize = stream . Length ;
111
- int blockCount = ( int ) ( ( fileSize + BLOCK_SIZE - 1 ) / BLOCK_SIZE ) ;
111
+ long blockCount = ( fileSize + BLOCK_SIZE - 1 ) / BLOCK_SIZE ;
112
112
113
113
//check resume record file
114
114
ResumeInfo resumeInfo = null ;
@@ -136,7 +136,7 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
136
136
}
137
137
138
138
//calc upload progress
139
- for ( int blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
139
+ for ( long blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
140
140
{
141
141
string context = resumeInfo . Contexts [ blockIndex ] ;
142
142
if ( ! string . IsNullOrEmpty ( context ) )
@@ -152,16 +152,16 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
152
152
//check not finished blocks to upload
153
153
UploadControllerAction upCtrl = putExtra . UploadController ( ) ;
154
154
ManualResetEvent manualResetEvent = new ManualResetEvent ( false ) ;
155
- Dictionary < int , byte [ ] > blockDataDict = new Dictionary < int , byte [ ] > ( ) ;
156
- Dictionary < int , HttpResult > blockMakeResults = new Dictionary < int , HttpResult > ( ) ;
155
+ Dictionary < long , byte [ ] > blockDataDict = new Dictionary < long , byte [ ] > ( ) ;
156
+ Dictionary < long , HttpResult > blockMakeResults = new Dictionary < long , HttpResult > ( ) ;
157
157
Dictionary < string , long > uploadedBytesDict = new Dictionary < string , long > ( ) ;
158
158
uploadedBytesDict . Add ( "UploadProgress" , uploadedBytes ) ;
159
159
byte [ ] blockBuffer = new byte [ BLOCK_SIZE ] ;
160
- for ( int blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
160
+ for ( long blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
161
161
{
162
162
string context = resumeInfo . Contexts [ blockIndex ] ;
163
163
if ( string . IsNullOrEmpty ( context ) )
164
- {
164
+ {
165
165
//check upload controller action before each chunk
166
166
while ( true )
167
167
{
@@ -200,7 +200,7 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
200
200
{
201
201
processMakeBlocks ( blockDataDict , upToken , putExtra , resumeInfo , blockMakeResults , uploadedBytesDict , fileSize ) ;
202
202
//check mkblk results
203
- foreach ( int blkIndex in blockMakeResults . Keys )
203
+ foreach ( int blkIndex in blockMakeResults . Keys )
204
204
{
205
205
HttpResult mkblkRet = blockMakeResults [ blkIndex ] ;
206
206
if ( mkblkRet . Code != 200 )
@@ -292,15 +292,15 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
292
292
return result ;
293
293
}
294
294
295
- private void processMakeBlocks ( Dictionary < int , byte [ ] > blockDataDict , string upToken ,
296
- PutExtra putExtra , ResumeInfo resumeInfo , Dictionary < int , HttpResult > blockMakeResults ,
297
- Dictionary < string , long > uploadedBytesDict , long fileSize )
295
+ private void processMakeBlocks ( Dictionary < long , byte [ ] > blockDataDict , string upToken ,
296
+ PutExtra putExtra , ResumeInfo resumeInfo , Dictionary < long , HttpResult > blockMakeResults ,
297
+ Dictionary < string , long > uploadedBytesDict , long fileSize )
298
298
{
299
299
int taskMax = blockDataDict . Count ;
300
300
ManualResetEvent [ ] doneEvents = new ManualResetEvent [ taskMax ] ;
301
301
int eventIndex = 0 ;
302
302
object progressLock = new object ( ) ;
303
- foreach ( int blockIndex in blockDataDict . Keys )
303
+ foreach ( long blockIndex in blockDataDict . Keys )
304
304
{
305
305
//signal task
306
306
ManualResetEvent doneEvent = new ManualResetEvent ( false ) ;
@@ -333,9 +333,9 @@ private void MakeBlock(object resumeBlockerObj)
333
333
{
334
334
ResumeBlocker resumeBlocker = ( ResumeBlocker ) resumeBlockerObj ;
335
335
ManualResetEvent doneEvent = resumeBlocker . DoneEvent ;
336
- Dictionary < int , HttpResult > blockMakeResults = resumeBlocker . BlockMakeResults ;
336
+ Dictionary < long , HttpResult > blockMakeResults = resumeBlocker . BlockMakeResults ;
337
337
PutExtra putExtra = resumeBlocker . PutExtra ;
338
- int blockIndex = resumeBlocker . BlockIndex ;
338
+ long blockIndex = resumeBlocker . BlockIndex ;
339
339
HttpResult result = new HttpResult ( ) ;
340
340
//check whether to cancel
341
341
while ( true )
@@ -353,8 +353,8 @@ private void MakeBlock(object resumeBlockerObj)
353
353
result . Code = ( int ) HttpCode . USER_CANCELED ;
354
354
result . RefCode = ( int ) HttpCode . USER_CANCELED ;
355
355
result . RefText += string . Format ( "[{0}] [ResumableUpload] Info: upload task is aborted, mkblk {1}\n " ,
356
- DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss.ffff" ) , blockIndex ) ;
357
- blockMakeResults . Add ( blockIndex , result ) ;
356
+ DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss.ffff" ) , blockIndex ) ;
357
+ blockMakeResults . Add ( blockIndex , result ) ;
358
358
return ;
359
359
}
360
360
else
@@ -365,7 +365,7 @@ private void MakeBlock(object resumeBlockerObj)
365
365
366
366
byte [ ] blockBuffer = resumeBlocker . BlockBuffer ;
367
367
int blockSize = blockBuffer . Length ;
368
-
368
+
369
369
string upToken = resumeBlocker . UploadToken ;
370
370
Dictionary < string , long > uploadedBytesDict = resumeBlocker . UploadedBytesDict ;
371
371
long fileSize = resumeBlocker . FileSize ;
0 commit comments