镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-06 06:26:46 +00:00
extract mirror size from rsync provider automatically
这个提交包含在:
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -84,3 +85,14 @@ func GetJSON(url string, obj interface{}, client *http.Client) (*http.Response,
|
||||
}
|
||||
return resp, json.Unmarshal(body, obj)
|
||||
}
|
||||
|
||||
func ExtractSizeFromRsyncLog(content []byte) string {
|
||||
// (?m) flag enables multi-line mode
|
||||
re := regexp.MustCompile(`(?m)^Total file size: ([0-9\.]+[KMGTP]?) bytes`)
|
||||
matches := re.FindAllSubmatch(content, -1)
|
||||
// fmt.Printf("%q\n", matches)
|
||||
if len(matches) == 0 {
|
||||
return ""
|
||||
}
|
||||
return string(matches[len(matches)-1][1])
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户