Created a test for downloading the core with the core.

added some safe checks in the core
This commit is contained in:
2025-05-06 14:47:51 +02:00
parent 3bd305dc10
commit 37c404603d
2 changed files with 19 additions and 1 deletions

View File

@@ -98,8 +98,17 @@ function Core:download(file)
return false, "Invalid type: "..textutils.serialiseJSON(data) return false, "Invalid type: "..textutils.serialiseJSON(data)
end end
if fs.exists(file) then
fs.delete(file);
end
local fileStream = io.open(file, "w"); 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(); fileStream:close();
return true, "Success" return true, "Success"

9
downloadCore.lua Normal file
View File

@@ -0,0 +1,9 @@
require("core")
local core = Core.new();
core:connect();
core:download("core.lua");
core:disconnect();