-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
In comparison to the downloadGit function, this is superior but was never used. We should look into inserting it into the used function.
Especially in regards to the "UpdateObj", which is not used the downloadGit whatsoever.
---@param sourceObject table
---@param targetDirectory string
---@param updateObj table | nil
---@return table | nil
---@return boolean
function Net:downloadURL(sourceObject, targetDirectory, updateObj)
local sourceName = "default" or (updateObj and updateObj.sourceName)
if updateObj then
sourceObject.name = sourceObject.name or updateObj.name
end
if not sourceObject.name then
sourceObject.name = self:getNameFromURL(sourceObject.source[sourceName])
end
local request = http.get(sourceObject.source[sourceName])
if request then
local content = request.readAll()
request.close()
if content then
local file = fs.open(targetDirectory .. sourceObject.name, "w")
if not file then
os.execute("mkdir " .. targetDirectory)
file = fs.open(targetDirectory .. sourceObject.name, "w")
end
file.write(content)
file.close()
return sourceObject, true
end
end
return nil, false
endMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
Open