Fix consistent use of enabledForUpdates -> enableForUpdates

This commit is contained in:
Girish Ramakrishnan
2025-09-23 16:42:57 +02:00
parent c6afe4fd4e
commit 50d37ad752
4 changed files with 25 additions and 26 deletions

View File

@@ -64,7 +64,7 @@ const assert = require('node:assert'),
// filesystem - backupDir, noHardlinks
// mountpoint - mountPoint, prefix, noHardlinks
// encryption: 'encryptionPassword' and 'encryptedFilenames' is converted into an 'encryption' object using hush.js. Password is lost forever after conversion.
const BACKUP_TARGET_FIELDS = [ 'id', 'name', 'provider', 'configJson', 'limitsJson', 'retentionJson', 'schedule', 'encryptionJson', 'format', 'enabledForUpdates', 'contentsJson', 'creationTime', 'ts', 'integrityKeyPairJson' ].join(',');
const BACKUP_TARGET_FIELDS = [ 'id', 'name', 'provider', 'configJson', 'limitsJson', 'retentionJson', 'schedule', 'encryptionJson', 'format', 'enableForUpdates', 'contentsJson', 'creationTime', 'ts', 'integrityKeyPairJson' ].join(',');
function storageApi(backupSite) {
assert.strictEqual(typeof backupSite, 'object');
@@ -117,7 +117,7 @@ function postProcess(result) {
result.integrityKeyPair = result.integrityKeyPairJson ? safe.JSON.parse(result.integrityKeyPairJson) : null;
delete result.integrityKeyPairJson;
result.enabledForUpdates = !!result.enabledForUpdates;
result.enableForUpdates = !!result.enableForUpdates;
result.contents = safe.JSON.parse(result.contentsJson) || null;
delete result.contentsJson;
@@ -216,7 +216,7 @@ function hasContent({ contents }, id) {
async function listByContentForUpdates(id) {
assert.strictEqual(typeof id, 'string');
const results = await database.query(`SELECT ${BACKUP_TARGET_FIELDS} FROM backupSites WHERE enabledForUpdates=?`, [ true ]);
const results = await database.query(`SELECT ${BACKUP_TARGET_FIELDS} FROM backupSites WHERE enableForUpdates=?`, [ true ]);
results.forEach(function (result) { postProcess(result); });
return results.filter(r => hasContent(r, id));
@@ -235,7 +235,7 @@ async function update(site, data) {
const args = [];
const fields = [];
for (const k in data) {
if (k === 'name' || k === 'schedule' || k === 'enabledForUpdates') { // format, provider cannot be updated
if (k === 'name' || k === 'schedule' || k === 'enableForUpdates') { // format, provider cannot be updated
fields.push(k + ' = ?');
args.push(data[k]);
} else if (k === 'config' || k === 'limits' || k === 'retention' || k === 'contents') { // encryption cannot be updated
@@ -284,13 +284,13 @@ async function setRetention(backupSite, retention, auditSource) {
await eventlog.add(eventlog.ACTION_BACKUP_TARGET_UPDATE, auditSource, { backupSite, retention });
}
async function setEnabledForUpdates(backupSite, enabledForUpdates, auditSource) {
async function setEnabledForUpdates(backupSite, enableForUpdates, auditSource) {
assert.strictEqual(typeof backupSite, 'object');
assert.strictEqual(typeof enabledForUpdates, 'boolean');
assert.strictEqual(typeof enableForUpdates, 'boolean');
assert.strictEqual(typeof auditSource, 'object');
await update(backupSite, { enabledForUpdates });
await eventlog.add(eventlog.ACTION_BACKUP_TARGET_UPDATE, auditSource, { backupSite, enabledForUpdates });
await update(backupSite, { enableForUpdates });
await eventlog.add(eventlog.ACTION_BACKUP_TARGET_UPDATE, auditSource, { backupSite, enableForUpdates });
}
async function setEncryption(backupSite, data, auditSource) {
@@ -548,7 +548,7 @@ async function add(data, auditSource) {
debug('add: validating new storage configuration');
const sanitizedConfig = await storageApi({ provider }).verifyConfig({id, provider, config });
await database.query('INSERT INTO backupSites (id, name, provider, configJson, contentsJson, limitsJson, integrityKeyPairJson, retentionJson, schedule, encryptionJson, format, enabledForUpdates) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
await database.query('INSERT INTO backupSites (id, name, provider, configJson, contentsJson, limitsJson, integrityKeyPairJson, retentionJson, schedule, encryptionJson, format, enableForUpdates) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[ id, name, provider, JSON.stringify(sanitizedConfig), JSON.stringify(contents), JSON.stringify(limits), JSON.stringify(integrityKeyPair), JSON.stringify(retention), schedule, JSON.stringify(encryption), format, enableForUpdates ]);
debug('add: setting up new storage configuration');
@@ -571,7 +571,7 @@ async function addDefault(auditSource) {
schedule: '00 00 23 * * *',
format: 'tgz',
contents: null,
enabledForUpdates: true
enableForUpdates: true
};
return await add(defaultBackupSite, auditSource);
}