Commit 4179b71c authored by Leo Iannacone's avatar Leo Iannacone

fix appending more than one package with status building to status.packages -...

fix appending more than one package with status building to status.packages - preventing user double upload same package and ui store two same entries with status.building
parent 87084343
......@@ -14,24 +14,36 @@ function __watch_build_status (socket, status) {
utils.errors_handler('Broadcaster:__watch_build_status:JSON.parse(new_content) - ', err, socket)
return
}
// looking for same package already in status.packages
var index = -1
for(i = 0; i < status.packages.length; i++)
{
p = status.packages[i]
if ( p.package == data.package
&& p.distribution == data.distribution )
{
index = i
break
}
}
if (data.status == config.status.package.building) {
status.packages.push(data)
if (index == -1) { // not found in status.packages
status.packages.push(data)
socket.emit(config.events.broadcast.status_update, data)
return
}
}
else if (data.status == config.status.package.sucessed
|| data.status == config.status.package.failed )
if (data.status == config.status.package.successed
|| data.status == config.status.package.failed )
{
for(i = 0; i < status.packages.length; i++)
{
p = status.packages[i]
if ( p.package == data.package
&& p.distribution == data.distribution )
{
status.packages.splice(i, 1)
break
}
if (index >= 0) { // found in status.packages - remove
status.packages.splice(index, 1)
}
socket.emit(config.events.broadcast.status_update, data)
}
socket.emit(config.events.broadcast.status_update, data)
})
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment