Created a test for downloading the core with the core.
added some safe checks in the core
This commit is contained in:
11
core.lua
11
core.lua
@@ -98,8 +98,17 @@ function Core:download(file)
|
||||
return false, "Invalid type: "..textutils.serialiseJSON(data)
|
||||
end
|
||||
|
||||
if fs.exists(file) then
|
||||
fs.delete(file);
|
||||
end
|
||||
|
||||
local fileStream = io.open(file, "w");
|
||||
fileStream:write(data.fileContent);
|
||||
|
||||
if not fileStream then
|
||||
return false, "Failed to open fileStream"
|
||||
end
|
||||
|
||||
fileStream:write(data.data);
|
||||
fileStream:close();
|
||||
|
||||
return true, "Success"
|
||||
|
||||
9
downloadCore.lua
Normal file
9
downloadCore.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
require("core")
|
||||
|
||||
local core = Core.new();
|
||||
|
||||
core:connect();
|
||||
|
||||
core:download("core.lua");
|
||||
|
||||
core:disconnect();
|
||||
Reference in New Issue
Block a user