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) { authRouter.get('/job', function (req, res) {
try {
const result = db._frontend.all().toArray(); const result = db._frontend.all().toArray();
res.json(result); res.json(result);
} catch (err) {
// collection not (yet) available
res.json([]);
}
}) })
.summary('Return all job ids.') .summary('Return all job ids.')
.description(dd` .description(dd`

View File

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