Skip to content

Commit

Permalink
Updated Installer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophLHR committed Dec 7, 2023
1 parent 73519b4 commit 04ec0d6
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions scmInstaller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
---@class SCMInstaller
local SCMInstaller = {}


local files = {}
local source = "raw.githubusercontent.com/mc-cc-scripts/script-manager/Issue-30-Spilt-SCM/"


function SCMInstaller:getFilesTxt()
http.get(source .. "files.txt", nil, function(response)
local file = response.readLine()
while file ~= nil do
table.insert(files, file)
file = response.readLine()
end
response.close()
end)
function SCMInstaller:getFilesTxt(source)
local files = {}
print("Downloading from " .. source .. "files.txt")
local response = http.get(source .. "files.txt")
if response == nil or response.getResponseCode() ~= 200 then
error("Failed to download files.txt")
end
local file = response.readLine()
while file ~= nil do
table.insert(files, file)
file = response.readLine()
end
response.close()
return files
end

function SCMInstaller:delteFiles()
function SCMInstaller:deleteFiles(files)
for _, value in ipairs(files) do
print("Deleting File " .. value)
if fs.exists(value) then
Expand All @@ -28,15 +28,17 @@ function SCMInstaller:delteFiles()
end

-- download the files
function SCMInstaller:downloadFiles()
function SCMInstaller:downloadFiles(source, files)
for index, value in ipairs(files) do
http.get(source .. value, nil, function(response)
print('Downloading ' .. index .. ' of ' .. #files .. ' files: ' .. value)
local file = fs.open(value, "w")
file.write(response.readAll())
file.close()
response.close()
end)
print('Downloading ' .. index .. ' of ' .. #files .. ' files: ' .. value)
local response = http.get(source .. value)
if not response or response.getResponseCode() ~= 200 then
error("Failed to download " .. value)
end
local file = fs.open(value, "w")
file.write(response.readAll())
file.close()
response.close()
end
end

Expand Down

0 comments on commit 04ec0d6

Please sign in to comment.