1
0
Fork 0

handle a missing _frontend collection gracefully (#6750)

This commit is contained in:
Jan 2018-10-08 10:16:24 +02:00 committed by GitHub
parent 24c6a7037a
commit 66d04a10bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -396,8 +396,13 @@ authRouter.delete('/job/:id', function (req, res) {
`);
authRouter.get('/job', function (req, res) {
const result = db._frontend.all().toArray();
res.json(result);
try {
const result = db._frontend.all().toArray();
res.json(result);
} catch (err) {
// collection not (yet) available
res.json([]);
}
})
.summary('Return all job ids.')
.description(dd`

View File

@ -32,12 +32,7 @@ var shallowCopy = require('@arangodb/util').shallowCopy;
// //////////////////////////////////////////////////////////////////////////////
function getFrontendCollection () {
var frontend = db._collection('_frontend');
if (frontend === null) {
throw new Error('_frontend collection not (yet) available');
}
return frontend;
return db._collection('_frontend');
}
// //////////////////////////////////////////////////////////////////////////////
@ -54,7 +49,11 @@ exports.notifications.versions = function () {
var n = 'notifications';
var v = 'versions';
var d;
var frontend = getFrontendCollection();
let frontend = getFrontendCollection();
if (!frontend) {
// collection not (yet) available
return { versions: {} };
}
try {
d = frontend.document(n);
@ -84,14 +83,18 @@ exports.notifications.versions = function () {
// //////////////////////////////////////////////////////////////////////////////
exports.notifications.setVersions = function (data) {
var n = 'notifications';
var d;
var frontend = getFrontendCollection();
const n = 'notifications';
let frontend = getFrontendCollection();
if (!frontend) {
// collection not (yet) available
return;
}
try {
d = frontend.document(n);
frontend.document(n);
} catch (err) {
d = frontend.save({ _key: n });
frontend.save({ _key: n });
}
frontend.update(n, data);