1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-06 06:26:46 +00:00

extract mirror size from rsync provider automatically

这个提交包含在:
zyx
2019-04-13 01:27:35 +08:00
父节点 a283328dc4
当前提交 d0deeb19a9
共有 9 个文件被更改,包括 89 次插入2 次删除

查看文件

@@ -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])
}