From 8f22b594d404d39835ce80a8240eb7e36ff0b6fc Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 11 Jan 2019 14:22:52 +0800 Subject: [PATCH] fix bugs in fileshare --- programs/fileshare/fget.lua | 11 ++++++++--- programs/fileshare/fshare.lua | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/programs/fileshare/fget.lua b/programs/fileshare/fget.lua index 8026d14..085d0fb 100644 --- a/programs/fileshare/fget.lua +++ b/programs/fileshare/fget.lua @@ -40,9 +40,14 @@ if(not modem.open(22)) then return end -print("Connecting to " .. server .. " at port " .. port) +if(opts["b"]) then + print("Broadcasting at port " .. port) + modem.broadcast(port,"fs_req",filename) +else + print("Connecting to " .. server .. " at port " .. port) + modem.send(server,port,"fs_req",filename) +end print("Press Ctrl+C will stop this process") -modem.send(server,port,"fs_req",filename) while true do local e=WaitMultipleEvent("modem_message","interrupted") if(e.event=="modem_message" and e.port==22) then @@ -58,7 +63,7 @@ while true do if(not ret) then print("[Error] Failed while writing file: " .. err) else - print("[Done] Data written to file: " .. err) + print("[Done] Data written to file: " .. localfile) end f:close() end diff --git a/programs/fileshare/fshare.lua b/programs/fileshare/fshare.lua index 9cbf247..fc1e1cf 100644 --- a/programs/fileshare/fshare.lua +++ b/programs/fileshare/fshare.lua @@ -100,6 +100,6 @@ if(opts["d"]) then PushEvent(thisid) print("[Done] FileShare Server started.") else -- Run in foreground - fss_server_main() + fss_server_main(print,table.pack("modem_message","fss_stop","interrupted")) print("[Stopped] File Share Server stopped.") end