diff options
| author | ruki <[email protected]> | 2022-06-16 00:29:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-06-16 00:29:09 +0800 |
| commit | ea89ffdb54ecc2bfb34f7a3162f216207ddf13ff (patch) | |
| tree | 38fdd8da9cb4fea8bd320be2c27c1a24287180ea /xmake/modules | |
| parent | 78e01e055477f407d6782075ae5cf6de0abf38f5 (diff) | |
improve to send/recv empty file
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/service/stream.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/xmake/modules/private/service/stream.lua b/xmake/modules/private/service/stream.lua index 24f664a2a..f674125e5 100644 --- a/xmake/modules/private/service/stream.lua +++ b/xmake/modules/private/service/stream.lua @@ -195,7 +195,7 @@ function stream:send_file(filepath, opt) local ok = false local sock = self._SOCK local file = io.open(filepath, 'rb') - if file then + if file and file:size() > 0 then local send = sock:sendfile(file, {block = true}) if send > 0 then ok = true @@ -352,8 +352,10 @@ end function stream:recv_file(filepath) local size, flags = self:recv_header() if size then - -- empty file? we need not create file + -- empty file? we just create an empty file if size == 0 then + local file = io.open(filepath, "wb") + file:close() return size end local result |
