Skip to content

Commit f2171fa

Browse files
committed
test do not merge
1 parent 07548da commit f2171fa

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

qiniu/resumable_io.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Qiniu_Rio_PutExtra
1212
public $Params = null;
1313
public $MimeType = null;
1414
public $ChunkSize = 0; // 可选。每次上传的Chunk大小
15-
public $TryTimes = 0; // 可选。尝试次数
15+
public $TryTimes = 3; // 可选。尝试次数
1616
public $Progresses = null; // 可选。上传进度:[]BlkputRet
1717
public $Notify = null; // 进度通知:func(blkIdx int, blkSize int, ret *BlkputRet)
1818
public $NotifyErr = null; // 错误通知:func(blkIdx int, blkSize int, err error)
@@ -118,13 +118,24 @@ function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra) // => ($putRet,
118118
$progresses = array();
119119
$uploaded = 0;
120120
while ($uploaded < $fsize) {
121+
$tried = 0;
122+
$tryTimes = ($putExtra->TryTimes > 0) ? $putExtra->TryTimes : 1;
121123
if ($fsize < $uploaded + QINIU_RIO_BLOCK_SIZE) {
122124
$bsize = $fsize - $uploaded;
123125
} else {
124126
$bsize = QINIU_RIO_BLOCK_SIZE;
125127
}
126-
list($blkputRet, $err) = Qiniu_Rio_Mkblock($self, $QINIU_UP_HOST, $body, $bsize);
127-
$host = $blkputRet['host'];
128+
while ($tried < $tryTimes) {
129+
list($blkputRet, $err) = Qiniu_Rio_Mkblock($self, $QINIU_UP_HOST, $body, $bsize);
130+
if ($err === null) {
131+
break;
132+
}
133+
$tried += 1;
134+
continue;
135+
}
136+
if ($err !== null) {
137+
return array(null, $err);
138+
}
128139
$uploaded += $bsize;
129140
$progresses []= $blkputRet;
130141
}

0 commit comments

Comments
 (0)