File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/main/java/com/qiniu/storage Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -61,11 +61,13 @@ private Response upload0() throws QiniuException {
61
61
long uploaded = 0 ;
62
62
int ret = 0 ;
63
63
boolean retry = false ;
64
+ boolean eof = false ;
64
65
65
- while (size == 0 ) {
66
+ while (size == 0 && ! eof ) {
66
67
int bufferIndex = 0 ;
67
68
int blockSize = 0 ;
68
69
70
+ //try to read the full BLOCK or until the EOF
69
71
while (ret != -1 && bufferIndex != blockBuffer .length ) {
70
72
try {
71
73
blockSize = blockBuffer .length - bufferIndex ;
@@ -75,6 +77,8 @@ private Response upload0() throws QiniuException {
75
77
throw new QiniuException (e );
76
78
}
77
79
if (ret != -1 ) {
80
+ //continue to read more
81
+ //advance bufferIndex
78
82
bufferIndex += ret ;
79
83
if (ret == 0 ) {
80
84
try {
@@ -84,10 +88,13 @@ private Response upload0() throws QiniuException {
84
88
}
85
89
}
86
90
} else {
91
+ eof = true ;
92
+ //file EOF here, trigger outer while-loop finish
87
93
size = uploaded + bufferIndex ;
88
94
}
89
95
}
90
96
97
+ //mkblk request
91
98
long crc = Crc32 .bytes (blockBuffer , 0 , bufferIndex );
92
99
Response response = null ;
93
100
QiniuException temp = null ;
You can’t perform that action at this time.
0 commit comments