Add locked flag to settings table

This commit is contained in:
Girish Ramakrishnan
2019-01-25 14:57:07 -08:00
parent c15449492a
commit 8fdc9939cd
7 changed files with 57 additions and 11 deletions

View File

@@ -35,6 +35,7 @@ exports = module.exports = {
getPlatformConfig: getPlatformConfig,
setPlatformConfig: setPlatformConfig,
get: get,
getAll: getAll,
// booleans. if you add an entry here, be sure to fix getAll
@@ -54,7 +55,7 @@ exports = module.exports = {
CLOUDRON_NAME_KEY: 'cloudron_name',
// blobs
CLOUDRON_AVATAR_KEY: 'cloudron_avatar', // not stored in db
CLOUDRON_AVATAR_KEY: 'cloudron_avatar', // not stored in db but can be used for locked flag
on: on,
removeListener: removeListener
@@ -488,3 +489,15 @@ function getAll(callback) {
callback(null, result);
});
}
function get(name, callback) {
assert.strictEqual(typeof name, 'string');
assert.strictEqual(typeof callback, 'function');
settingsdb.get(name, function (error, result) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(null, gDefaults[exports.PLATFORM_CONFIG_KEY]);
if (error) return callback(new SettingsError(SettingsError.INTERNAL_ERROR, error));
callback(null, result);
});
}