Skip to content

Commit 7d730af

Browse files
committed
fix: no time duration while http failed
1 parent 699f32b commit 7d730af

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

conf.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
token: 52121225
2-
api: http://127.0.0.1/Queue
1+
token: 2QzeQ8wpKDa7ftxxDydsRBJZJsHQn83bnB6XBxzZ87ysa6nek8zARd7MwkQcGFa7
2+
api: https://lite.aoaoao.me/Queue
33
taskNum: 4
4-
Duration: 1
4+
Duration: 20

debug

-7.17 MB
Binary file not shown.

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (c *taskConfig) getConf() (*taskConfig, error) {
3939

4040
func main() {
4141

42-
fmt.Println("Cloudreve Queue Go Version")
42+
fmt.Println("Cloudreve Queue Go Version 1.0")
4343
fmt.Println("Author: AaronLiu <abslant@foxmail.com>")
4444
fmt.Println("")
4545
var config taskConfig

onedrive/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66
"encoding/json"
77
"fmt"
88
"io/ioutil"
9+
"log"
910
"net/http"
1011
"os"
1112
"strconv"
13+
"time"
1214
)
1315

1416
//APIURL Graph API URL
@@ -175,6 +177,7 @@ func (client *Client) apiPost(path string, jsonStr []byte) Response {
175177
//apiPut 发送PUT请求
176178
func (client *Client) apiPut(path string, stream *os.File) Response {
177179
if client.Tried > maxTry {
180+
178181
return buildResponseResult("PUT failed, reached the maximum number of attempts.", 0)
179182
}
180183

@@ -188,6 +191,8 @@ func (client *Client) apiPut(path string, stream *os.File) Response {
188191
res, err := client.HTTPClient.Do(req)
189192
if err != nil {
190193
client.Tried++
194+
log.Println("PUT failed, retrying...")
195+
time.Sleep(time.Duration(5*client.Tried*client.Tried) * time.Second)
191196
return client.apiPut(path, stream)
192197
}
193198
defer res.Body.Close()

0 commit comments

Comments
 (0)