diff options
| author | ruki <[email protected]> | 2022-05-11 22:40:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-11 22:40:15 +0800 |
| commit | 00c362f3009600660daa5ef00ea3c6f38069c2a5 (patch) | |
| tree | f3b36e777ee332d55e263a8ce0bbc3a6bcd929cf | |
| parent | 278ea7627a3c76e2712c1117ced1bdc3045bdb9d (diff) | |
remove archive files
3 files changed, 31 insertions, 54 deletions
diff --git a/xmake/modules/private/service/remote_build/client.lua b/xmake/modules/private/service/remote_build/client.lua index 2874ac154..12cfb7a30 100644 --- a/xmake/modules/private/service/remote_build/client.lua +++ b/xmake/modules/private/service/remote_build/client.lua @@ -26,7 +26,6 @@ import("core.base.option") import("core.base.scheduler") import("core.project.config", {alias = "project_config"}) import("lib.detect.find_tool") -import("utils.archive.archive", {alias = "archive_files"}) import("private.service.config") import("private.service.message") import("private.service.client") @@ -190,7 +189,6 @@ function remote_build_client:sync() local errors local ok = false local diff_files - local archive_diff_file print("%s: sync files in %s:%d ..", self, addr, port) while sock do @@ -205,18 +203,11 @@ function remote_build_client:sync() break end - -- archive diff files - print("Archiving files ..") - archive_diff_file, errors = self:_archive_diff_files(diff_files) - if not archive_diff_file or not os.isfile(archive_diff_file) then - break - end - -- do sync - cprint("Uploading files with ${bright}%d${clear} bytes ..", os.filesize(archive_diff_file)) + cprint("Uploading files ..") local send_ok = false if stream:send_msg(message.new_sync(session_id, diff_files, {token = self:token()}), {compress = true}) and stream:flush() then - if stream:send_file(archive_diff_file) and stream:flush() then + if self:_send_diff_files(stream, diff_files) then send_ok = true end end @@ -235,9 +226,6 @@ function remote_build_client:sync() end break end - if archive_diff_file then - os.tryrm(archive_diff_file) - end if ok then print("%s: sync files ok!", self) else @@ -431,25 +419,19 @@ function remote_build_client:_diff_files(stream) return result, errors end --- archive diff files -function remote_build_client:_archive_diff_files(diff_files) - local archivefile = os.tmpfile() .. ".zip" - local archivedir = path.directory(archivefile) - if not os.isdir(archivedir) then - os.mkdir(archivedir) - end - local filelist = {} +-- send diff files +function remote_build_client:_send_diff_files(stream, diff_files) for _, fileitem in ipairs(diff_files.inserted) do - table.insert(filelist, fileitem) + if not stream:send_file(fileitem, {compress = os.filesize(fileitem) > 4096}) then + return false + end end for _, fileitem in ipairs(diff_files.modified) do - table.insert(filelist, fileitem) - end - local ok = archive_files(archivefile, filelist, {curdir = self:projectdir()}) - if not ok then - return nil, "archive files failed!" + if not stream:send_file(fileitem, {compress = os.filesize(fileitem) > 4096}) then + return false + end end - return archivefile + return stream:flush() end -- read stdin data diff --git a/xmake/modules/private/service/remote_build/environment.lua b/xmake/modules/private/service/remote_build/environment.lua index 37250a227..019b502dc 100644 --- a/xmake/modules/private/service/remote_build/environment.lua +++ b/xmake/modules/private/service/remote_build/environment.lua @@ -22,21 +22,5 @@ import("lib.detect.find_tool") -- check environment --- --- ensure that we can find some basic tools: zip, 7zip, ... --- --- If these tools not exist, we will install it first. --- function check(server_side) - if server_side then - -- unzip or 7zip is necessary - if not find_tool("unzip") and not find_tool("7z") then - raise("unzip or 7zip not found! we need install it first") - end - else - -- zip or 7zip is necessary - if not find_tool("zip") and not find_tool("7z") then - raise("zip or 7zip not found! we need install it first") - end - end end diff --git a/xmake/modules/private/service/remote_build/session.lua b/xmake/modules/private/service/remote_build/session.lua index 79a6c6943..0ba605077 100644 --- a/xmake/modules/private/service/remote_build/session.lua +++ b/xmake/modules/private/service/remote_build/session.lua @@ -26,7 +26,6 @@ import("core.base.global") import("core.base.option") import("core.base.hashset") import("core.base.scheduler") -import("utils.archive.extract", {alias = "extract_archive"}) import("private.service.config") import("private.service.message") import("private.service.remote_build.filesync", {alias = "new_filesync"}) @@ -143,14 +142,9 @@ function session:sync(respmsg) local manifest = assert(body.manifest, "manifest not found!") local filesync = self:_filesync() local sourcedir = self:sourcedir() - local archivefile = os.tmpfile() .. ".zip" - local archivedir = archivefile .. ".dir" + local archivedir = os.tmpfile() .. ".dir" vprint("%s: sync files in %s ..", self, self:sourcedir()) - if stream:recv_file(archivefile) then - vprint("receive archive file, size: %d", os.filesize(archivefile)) - - -- extract archive file - extract_archive(archivefile, archivedir) + if self:_recv_syncfiles(manifest, archivedir) then -- do sync for _, fileitem in ipairs(manifest.inserted) do @@ -177,7 +171,6 @@ function session:sync(respmsg) else raise("receive files failed!") end - os.tryrm(archivefile) os.tryrm(archivedir) vprint("%s: sync files ok", self) end @@ -349,6 +342,24 @@ function session:_send_data(data) end end +-- recv syncfiles +function session:_recv_syncfiles(manifest, outputdir) + local stream = self:stream() + for _, fileitem in ipairs(manifest.inserted) do + local filepath = path.join(outputdir, fileitem) + if not stream:recv_file(filepath) then + return false + end + end + for _, fileitem in ipairs(manifest.modified) do + local filepath = path.join(outputdir, fileitem) + if not stream:recv_file(filepath) then + return false + end + end + return true +end + function session:__tostring() return string.format("<session %s>", self:id()) end |
