mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-20 22:23:13 +00:00
JSON.parse env before checking for delta, and use progress.percentage
This commit is contained in:
parent
1bc149866d
commit
8e4e844cfa
@ -127,22 +127,24 @@ isValidPort = (port) ->
|
||||
|
||||
fetch = (app) ->
|
||||
onProgress = (progress) ->
|
||||
device.updateState(download_progress: progress.percent)
|
||||
device.updateState(download_progress: progress.percentage)
|
||||
|
||||
docker.getImage(app.imageId).inspectAsync()
|
||||
.catch (error) ->
|
||||
logSystemEvent(logTypes.downloadApp, app)
|
||||
device.updateState(status: 'Downloading', download_progress: 0)
|
||||
|
||||
if app.env.RESIN_DELTA?
|
||||
fetchPromise = dockerUtils.rsyncImageWithProgress(app.imageId, onProgress)
|
||||
else
|
||||
fetchPromise = dockerUtils.fetchImageWithProgress(app.imageId, onProgress)
|
||||
|
||||
fetchPromise.then ->
|
||||
logSystemEvent(logTypes.downloadAppSuccess, app)
|
||||
device.updateState(status: 'Idle', download_progress: null)
|
||||
docker.getImage(app.imageId).inspectAsync()
|
||||
Promise.try ->
|
||||
JSON.parse(app.env)
|
||||
.then (env) ->
|
||||
if env['RESIN_DELTA'] == '1'
|
||||
fetchPromise = dockerUtils.rsyncImageWithProgress(app.imageId, onProgress)
|
||||
else
|
||||
fetchPromise = dockerUtils.fetchImageWithProgress(app.imageId, onProgress)
|
||||
fetchPromise.then ->
|
||||
logSystemEvent(logTypes.downloadAppSuccess, app)
|
||||
device.updateState(status: 'Idle', download_progress: null)
|
||||
docker.getImage(app.imageId).inspectAsync()
|
||||
.catch (err) ->
|
||||
logSystemEvent(logTypes.downloadAppError, app, err)
|
||||
throw err
|
||||
|
@ -50,9 +50,10 @@ exports.rsyncImageWithProgress = (imgDest, onProgress) ->
|
||||
rsyncDiff = new Promise (resolve, reject) ->
|
||||
console.log("#{config.deltaHost}/api/v1/delta?src=#{imgSrc}&dest=#{imgDest}", timeout: 5 * 60 * 1000)
|
||||
progress request.get("#{config.deltaHost}/api/v1/delta?src=#{imgSrc}&dest=#{imgDest}", timeout: 5 * 60 * 1000)
|
||||
.on 'progress', onProgress
|
||||
.on 'progress', (progress) ->
|
||||
onProgress(percentage: progress.percent)
|
||||
.on 'end', ->
|
||||
onProgress(percent: 100)
|
||||
onProgress(percentage: 100)
|
||||
.on 'response', (res) ->
|
||||
if res.statusCode isnt 200
|
||||
reject()
|
||||
|
Loading…
Reference in New Issue
Block a user