mirror of https://gitee.com/bigwinds/arangodb
handle a missing _frontend collection gracefully (#6750)
This commit is contained in:
parent
24c6a7037a
commit
66d04a10bc
|
@ -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`
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue