mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Merge pull request #122 from Dahlgren/bugfix/missions-error
Handle errors while loading missions list
This commit is contained in:
commit
59b9c15869
@ -27,35 +27,40 @@ Missions.prototype.updateMissions = function (cb) {
|
||||
var self = this
|
||||
fs.readdir(this.missionsPath(), function (err, files) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
|
||||
if (cb) {
|
||||
cb(err)
|
||||
return cb(err)
|
||||
}
|
||||
} else {
|
||||
async.map(files, function (filename, cb) {
|
||||
fs.stat(self.missionPath(filename), function (err, stat) {
|
||||
if (err) {
|
||||
cb(err)
|
||||
}
|
||||
|
||||
cb(null, {
|
||||
dateCreated: new Date(stat.ctime),
|
||||
dateModified: new Date(stat.mtime),
|
||||
name: filename,
|
||||
size: stat.size,
|
||||
sizeFormatted: filesize(stat.size)
|
||||
})
|
||||
})
|
||||
}, function (err, missions) {
|
||||
if (!err) {
|
||||
self.missions = missions
|
||||
self.emit('missions', missions)
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb(err, missions)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
async.map(files, function (filename, cb) {
|
||||
fs.stat(self.missionPath(filename), function (err, stat) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
return cb(err)
|
||||
}
|
||||
|
||||
cb(null, {
|
||||
dateCreated: new Date(stat.ctime),
|
||||
dateModified: new Date(stat.mtime),
|
||||
name: filename,
|
||||
size: stat.size,
|
||||
sizeFormatted: filesize(stat.size)
|
||||
})
|
||||
})
|
||||
}, function (err, missions) {
|
||||
if (!err) {
|
||||
self.missions = missions
|
||||
self.emit('missions', missions)
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb(err, missions)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user