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

Commit

Permalink
Attempt to fix #251
Browse files Browse the repository at this point in the history
I’m not sure if this will work really. We’ll see though.
  • Loading branch information
oeed committed Jul 20, 2014
1 parent 65cf759 commit 4c33eef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
8 changes: 5 additions & 3 deletions System/API/Bedrock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,11 @@ function HandleTimer(self, event, timer)
if self.Timers[timer] then
local oldTimer = self.Timers[timer]
self.Timers[timer] = nil
oldTimer[1]()
if oldTimer[2] then
self:StartRepeatingTimer(oldTimer[1], oldTimer[3])
if oldTimer and oldTimer[1] then
oldTimer[1]()
if oldTimer[2] then
self:StartRepeatingTimer(oldTimer[1], oldTimer[3])
end
end
elseif self.OnTimer then
self.OnTimer(self, event, timer)
Expand Down
2 changes: 1 addition & 1 deletion System/API/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Defaults = {
DownloadPrereleases = {
Type = 'Bool',
Label = 'Download Betas',
Default = true,
Default = false,
},
StartupProgram = {
Type = 'Program',
Expand Down
1 change: 1 addition & 0 deletions System/Programs/Update OneOS.program/startup
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function downloadBlob(v)
local h = OneOS.FS.open('/'..v.path, 'w')
h.write(f.readAll())
h.close()
OneOS.Log.i('Downloaded: '..v.path)

if v.size then
downloadedBytes = downloadedBytes + v.size
Expand Down
41 changes: 8 additions & 33 deletions startup
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ if h then
version = h.readAll()
h.close()
else
local h = fs.open('/System/.version', 'w')
h.write('v1.2.0') --assumed minimum version. if there's a newer one it'll update them
h.close()
version = 'Not set. Using v1.2.0'
version = 'Not set'
end
Log.i('OneOS Version: '..version)

Expand Down Expand Up @@ -232,6 +229,7 @@ function LoadingScreen()
if not isDebug then
if math.floor(_*(8/#apis)) ~= currentImage then
currentImage = math.floor(_*(8/#apis))
Log.i('Loading image: System/Images/Boot/boot'..currentImage)
local image = paintutils.loadImage('System/Images/Boot/boot'..currentImage)
paintutils.drawImage(image, x, y)
sleep(0)
Expand Down Expand Up @@ -516,34 +514,6 @@ if not term.isColour() then
term.setCursorPos(1,1)

elseif Start() then
if fs.exists('/.update/') and fs.isDir('/.update/') then
if not fs.exists('/.update/.version') then
fs.delete('/.update/')
else

function installFolder(path)
for i, v in ipairs(fs.list('/.update/'..path)) do
Drawing.DrawArea(1, math.floor(Drawing.Screen.Height / 2), Drawing.Screen.Width, 1, ' ', colours.lightGrey, colours.white)
Drawing.DrawCharactersCenter(nil, 0, nil, nil, path .. v, colours.lightGrey, colours.white)
Drawing.DrawBuffer()
if fs.isDir('/.update/'..path .. v) then
fs.makeDir('/'..path .. v)
installFolder(path .. v .. '/')
else
fs.delete('/'..path .. v)
fs.move('/.update/'..path .. v, '/'..path .. v)
end
sleep(0)
end
end
Drawing.Clear(colours.white)
Drawing.DrawCharactersCenter(nil, -3, nil, nil, 'Installing Update', colours.blue, colours.white)
Drawing.DrawCharactersCenter(nil, -2, nil, nil, 'This may take a moment.', colours.grey, colours.white)
Drawing.DrawBuffer()
installFolder('')
fs.delete('/.update/')
end
end
os.run(getfenv(), '/System/main.lua')

local ok = nil
Expand Down Expand Up @@ -583,6 +553,7 @@ elseif Start() then
term.clear()
local w,h = term.getSize()
if fs.exists('System/Images/crash') then
Log.i('Loading image: System/Images/crash')
paintutils.drawImage(paintutils.loadImage('System/Images/crash'), (w-7)/2 + 1, 3)
end
term.setBackgroundColor(colours.grey)
Expand All @@ -604,7 +575,11 @@ elseif Start() then
term.clear()
local w,h = term.getSize()
if fs.exists('/System/Images/crash') then
paintutils.drawImage(paintutils.loadImage('/System/Images/crash'), (w-7)/2 + 1, 3)
Log.i('Loading image: System/Images/crash')
local img = paintutils.loadImage('/System/Images/crash')
if img and w then
paintutils.drawImage(img, (w-7)/2 + 1, 3)
end
else
table.insert(ok, 'Crash image nonexistent!')
end
Expand Down

0 comments on commit 4c33eef

Please sign in to comment.