Skip to content

Commit

Permalink
Update install.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
masx200 committed May 17, 2023
1 parent b4421be commit ce48a6f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ local function movefilesinfolder(src, dest, callback)

end

local function checkfilesexists(archivefile)
if os.exists(archivefile .. '.list') then
local installedlistfile = io.open(archivefile .. '.list', "r")
local function checkfilesexists(listfile)
if os.exists(listfile) then
local installedlistfile = io.open(listfile, "r")
if nil == installedlistfile then
print("open file: " .. archivefile .. '.list' .. " fail")
print("open file: " .. listfile .. " fail")
return
end
while (true) do
Expand All @@ -47,10 +47,11 @@ end
function main()

local name = "leetcode-treenode-cpp"
local version = "1.1.8"
local version = "1.1.9"
local folder = name .. "-" .. version
local archivefile = path.join('downloads', folder .. '.tar.gz')
if checkfilesexists(archivefile) then return end
local listfile = path.join('downloads', folder .. '.list')
if checkfilesexists(listfile) then return end
if not os.exists(archivefile) then
local url = 'https://ghproxy.com/https://github.com/masx200/' .. name ..
'/archive/' .. version .. '.tar.gz'
Expand All @@ -69,15 +70,15 @@ function main()
print("remove folder:" .. name)
os.rmdir(name)
end
local installedlistfile = io.open(archivefile .. '.list', "w")
local installedlistfile = io.open(listfile, "w")
if nil == installedlistfile then
print("open file: " .. archivefile .. '.list' .. " fail")
print("open file: " .. listfile .. " fail")
return
end
movefilesinfolder(src, name, function(installedfile)
installedlistfile:write(installedfile)
installedlistfile:write("\n")
end)
installedlistfile:close()
print("save installedlistfile to " .. archivefile .. '.list')
print("save installedlistfile to " .. listfile)
end

0 comments on commit ce48a6f

Please sign in to comment.