mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: generating token and callback url for OSS muiltpart upload, support resume upload in sever-side uploading for OSS
This commit is contained in:
@@ -279,7 +279,7 @@ func (client *Client) Upload(ctx context.Context, file fsctx.FileHeader) error {
|
||||
|
||||
// Initial chunk groups
|
||||
chunks := chunk.NewChunkGroup(file, client.Policy.OptionsSerialized.ChunkSize, &backoff.ConstantBackoff{
|
||||
Max: model.GetIntSetting("onedrive_chunk_retries", 5),
|
||||
Max: model.GetIntSetting("chunk_retries", 5),
|
||||
Sleep: chunkRetrySleep,
|
||||
})
|
||||
|
||||
@@ -327,7 +327,7 @@ func (client *Client) SimpleUpload(ctx context.Context, dst string, body io.Read
|
||||
if v, ok := ctx.Value(fsctx.RetryCtx).(int); ok {
|
||||
retried = v
|
||||
}
|
||||
if retried < model.GetIntSetting("onedrive_chunk_retries", 5) {
|
||||
if retried < model.GetIntSetting("chunk_retries", 5) {
|
||||
retried++
|
||||
util.Log().Debug("文件[%s]上传失败[%s],5秒钟后重试", dst, err)
|
||||
time.Sleep(time.Duration(5) * time.Second)
|
||||
|
||||
@@ -535,7 +535,7 @@ func TestClient_UploadChunk(t *testing.T) {
|
||||
|
||||
// 最后分片,第一次失败,重试后成功
|
||||
{
|
||||
cache.Set("setting_onedrive_chunk_retries", "1", 0)
|
||||
cache.Set("setting_chunk_retries", "1", 0)
|
||||
client.Credential.ExpiresIn = 0
|
||||
go func() {
|
||||
time.Sleep(time.Duration(2) * time.Second)
|
||||
@@ -641,7 +641,7 @@ func TestClient_SimpleUpload(t *testing.T) {
|
||||
client, _ := NewClient(&model.Policy{})
|
||||
client.Credential.AccessToken = "AccessToken"
|
||||
client.Credential.ExpiresIn = time.Now().Add(time.Duration(100) * time.Hour).Unix()
|
||||
cache.Set("setting_onedrive_chunk_retries", "1", 0)
|
||||
cache.Set("setting_chunk_retries", "1", 0)
|
||||
|
||||
// 请求失败,并重试
|
||||
{
|
||||
@@ -651,7 +651,7 @@ func TestClient_SimpleUpload(t *testing.T) {
|
||||
asserts.Nil(res)
|
||||
}
|
||||
|
||||
cache.Set("setting_onedrive_chunk_retries", "0", 0)
|
||||
cache.Set("setting_chunk_retries", "0", 0)
|
||||
// 返回未知响应
|
||||
{
|
||||
client.Credential.ExpiresIn = time.Now().Add(time.Duration(100) * time.Hour).Unix()
|
||||
|
||||
Reference in New Issue
Block a user