summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-06-17 00:22:53 +0800
committerruki <[email protected]>2022-06-17 00:22:53 +0800
commit91395ec93c42631a613a64fd1b11ab6610bf3ea4 (patch)
treea6ce7be14eabdc358987fa64049d51ab197c58e4
parentf8dc2e1f9c0262710160649c56a59e681cdb375b (diff)
improve stream and remote build
-rw-r--r--xmake/modules/private/service/remote_build/client.lua6
-rw-r--r--xmake/modules/private/service/remote_build/server_session.lua2
-rw-r--r--xmake/modules/private/service/stream.lua9
3 files changed, 12 insertions, 5 deletions
diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua
index 283480260..f76699790 100644
--- a/xmake/modules/private/service/remote_build/client.lua
+++ b/xmake/modules/private/service/remote_build/client.lua
@@ -476,9 +476,9 @@ function remote_build_client:_send_diff_files(stream, diff_files)
totalsize = totalsize + filesize
compressed_size = compressed_size + compressed_real
end
- cprint("Uploading ${bright}%d%%${clear} ..", math.floor(count * 100 / totalcount))
- cprint("${bright}%d${clear} files, ${bright}%d (%d%%)${clear} bytes are uploaded, spent ${bright}%d${clear} ms.",
- totalcount, compressed_size, math.floor(compressed_size * 100 / totalsize), os.mclock() - startime)
+ cprint("Uploading ${bright}%s%%${clear} ..", totalcount > 0 and math.floor(count * 100 / totalcount) or 0)
+ cprint("${bright}%s${clear} files, ${bright}%s (%s%%)${clear} bytes are uploaded, spent ${bright}%s${clear} ms.",
+ totalcount, compressed_size, totalsize > 0 and math.floor(compressed_size * 100 / totalsize) or 0, os.mclock() - startime)
return stream:flush()
end
diff --git a/xmake/modules/private/service/remote_build/server_session.lua b/xmake/modules/private/service/remote_build/server_session.lua
index 761eb7ee2..340d9934d 100644
--- a/xmake/modules/private/service/remote_build/server_session.lua
+++ b/xmake/modules/private/service/remote_build/server_session.lua
@@ -350,12 +350,14 @@ function server_session:_recv_syncfiles(manifest, outputdir)
for _, fileitem in ipairs(manifest.inserted) do
local filepath = path.join(outputdir, fileitem)
if not stream:recv_file(filepath) then
+ dprint("%s: recv %s failed!", self, filepath)
return false
end
end
for _, fileitem in ipairs(manifest.modified) do
local filepath = path.join(outputdir, fileitem)
if not stream:recv_file(filepath) then
+ dprint("%s: recv %s failed!", self, filepath)
return false
end
end
diff --git a/xmake/modules/private/service/stream.lua b/xmake/modules/private/service/stream.lua
index f674125e5..561fea5f3 100644
--- a/xmake/modules/private/service/stream.lua
+++ b/xmake/modules/private/service/stream.lua
@@ -173,7 +173,7 @@ function stream:send_file(filepath, opt)
local flags = 0
local tmpfile
local originsize = os.filesize(filepath)
- if opt.compress then
+ if opt.compress and originsize > 0 then
flags = bit.bor(flags, HEADER_FLAG_COMPRESS_LZ4)
tmpfile = os.tmpfile()
lz4.compress_file(filepath, tmpfile)
@@ -186,6 +186,11 @@ function stream:send_file(filepath, opt)
return
end
+ -- empty file?
+ if size == 0 then
+ return 0, 0
+ end
+
-- flush cache data first
if not self:flush() then
return
@@ -195,7 +200,7 @@ function stream:send_file(filepath, opt)
local ok = false
local sock = self._SOCK
local file = io.open(filepath, 'rb')
- if file and file:size() > 0 then
+ if file then
local send = sock:sendfile(file, {block = true})
if send > 0 then
ok = true