Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
Shutdown fixes and changed updater
Browse files Browse the repository at this point in the history
  • Loading branch information
oeed committed Mar 8, 2014
1 parent a966a79 commit ed082e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions System/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function Initialise()
EventRegister('mouse_drag', TryClick)
EventRegister('monitor_touch', TryClick)
EventRegister('oneos_draw', Draw)
EventRegister('oneos_shutdown', function(ev, restart)Shutdown(true, restart)end)
EventRegister('key', HandleKey)
EventRegister('char', HandleKey)
EventRegister('timer', Update)
Expand Down Expand Up @@ -442,16 +443,16 @@ function AnimateShutdown()
term.clear()
end

function Shutdown(restart, force)
function Shutdown(force, restart)
local success = true
if not force then
os.queueEvent('oneos_shutdown', restart)
for i, program in ipairs(Current.Programs) do
if not program:Close() then
success = false
end
end
end

if success and not restart then
if force then
os.shutdown()
Expand Down Expand Up @@ -488,7 +489,7 @@ function Shutdown(restart, force)
end

function Restart(force)
Shutdown(true, force)
Shutdown(force, true)
end

function EventRegister(event, func)
Expand Down
10 changes: 5 additions & 5 deletions System/update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ function downloadBlob(v)
return
end
if v.type == 'tree' then
print('Making folder: '..'/.update/'..Settings.InstallPath..v.path, 'Making folder: '..'/.update/'..Settings.InstallPath..v.path)
fs.makeDir('/.update/'..Settings.InstallPath..v.path)
print('Making folder: '..'/'..Settings.InstallPath..v.path, 'Making folder: '..'/'..Settings.InstallPath..v.path)
fs.makeDir('/'..Settings.InstallPath..v.path)
else
print('(' .. Settings.DownloadedBytes .. 'B/' .. Settings.TotalBytes .. 'B) Downloading file: '..Settings.InstallPath..v.path, Settings.InstallPath..v.path, 'Downloading files...')
local f = http.get(('https://raw.github.com/'..Settings.GitHubUsername..'/'..Settings.GitHubRepoName..'/'..latestReleaseTag..Settings.InstallPath..v.path):gsub(' ','%%20'))
if not f then
error('Downloading failed, try again. '..('https://raw.github.com/'..Settings.GitHubUsername..'/'..Settings.GitHubRepoName..'/'..latestReleaseTag..Settings.InstallPath..v.path):gsub(' ','%%20'))
end
local h = fs.open('/.update/'..Settings.InstallPath..v.path, 'w')
local h = fs.open('/'..Settings.InstallPath..v.path, 'w')
h.write(f.readAll())
h.close()

Expand All @@ -143,7 +143,7 @@ function downloadBlob(v)
end

local downloads = {}
fs.makeDir('/.update/')
fs.makeDir('/')
for i, v in ipairs(tree) do
--parallel.waitForAny(function() sleep(0) end, function()downloadBlob(v)end)
--downloadBlob(v)
Expand All @@ -154,6 +154,6 @@ end
Settings.UpdateFunction()
parallel.waitForAll(unpack(downloads))

local h = fs.open('/.update/.version', 'w')
local h = fs.open('/System/.version', 'w')
h.write(latestReleaseTag)
h.close()

0 comments on commit ed082e0

Please sign in to comment.