diff options
| author | ruki <[email protected]> | 2022-05-11 22:59:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-11 22:59:04 +0800 |
| commit | 8dc3633d4e1611a409dd1918fba2b634fb0e968f (patch) | |
| tree | 62d74c1c98bae31bd292349327fc76aa8004aead | |
| parent | 93a57b9ed86c527b4a3536d93487905d0f87a44d (diff) | |
improve upload tips
| -rw-r--r-- | xmake/modules/private/service/remote_build/client.lua | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua index bd0938a4c..249d929f9 100644 --- a/xmake/modules/private/service/remote_build/client.lua +++ b/xmake/modules/private/service/remote_build/client.lua @@ -423,9 +423,15 @@ end function remote_build_client:_send_diff_files(stream, diff_files) local count = 0 local totalsize = 0 + local totalcount = #(diff_files.inserted or {}) + #(diff_files.modified or {}) + local time = os.mclock() for _, fileitem in ipairs(diff_files.inserted) do local filesize = os.filesize(fileitem) - vprint("sending %s, %d bytes ..", fileitem, filesize) + if os.mclock() - time > 1000 then + cprint("Uploading ${bright}%d%%${clear} ..", math.floor(count * 100 / totalcount)) + time = os.mclock() + end + vprint("uploading %s, %d bytes ..", fileitem, filesize) if not stream:send_file(fileitem, {compress = filesize > 4096}) then return false end @@ -434,14 +440,19 @@ function remote_build_client:_send_diff_files(stream, diff_files) end for _, fileitem in ipairs(diff_files.modified) do local filesize = os.filesize(fileitem) - vprint("sending %s, %d bytes ..", fileitem, filesize) + if os.mclock() - time > 1000 then + cprint("Uploading ${bright}%d%%${clear} ..", math.floor(count * 100 / totalcount)) + time = os.mclock() + end + vprint("uploading %s, %d bytes ..", fileitem, filesize) if not stream:send_file(fileitem, {compress = filesize > 4096}) then return false end count = count + 1 totalsize = totalsize + filesize end - cprint("${bright}%d${clear} files, ${bright}%d${clear} bytes are uploaded.", count, totalsize) + cprint("Uploading ${bright}%d%%${clear} ..", math.floor(count * 100 / totalcount)) + cprint("${bright}%d${clear} files, ${bright}%d${clear} bytes are uploaded, ${bright}%d${clear} ms.", totalcount, totalsize, os.mclock() - time) return stream:flush() end |
