do not store "null" as string in database
in other news, JSON.parse('null') returns null.
This commit is contained in:
@@ -101,7 +101,7 @@ exports.up = async function (db) {
|
||||
|
||||
await db.runSql('START TRANSACTION');
|
||||
await db.runSql('INSERT INTO backupSites (id, name, provider, configJson, limitsJson, integrityKeyPairJson, retentionJson, schedule, encryptionJson, format, enableForUpdates) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
[ id, name, provider, JSON.stringify(config), JSON.stringify(limits), JSON.stringify(integrityKeyPair), JSON.stringify(retention), schedule, JSON.stringify(encryption), format, enableForUpdates ]);
|
||||
[ id, name, provider, JSON.stringify(config), JSON.stringify(limits), JSON.stringify(integrityKeyPair), JSON.stringify(retention), schedule, encryption ? JSON.stringify(encryption) : null, format, enableForUpdates ]);
|
||||
await deleteOldSettings(db);
|
||||
await db.runSql('UPDATE tasks SET type=? WHERE type=?', [ `backup_${id}`, 'backup' ]); // migrate the tasks
|
||||
await db.runSql('COMMIT');
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
const crypto = require('node:crypto'),
|
||||
path = require('node:path'),
|
||||
paths = require('../src/paths.js');
|
||||
paths = require('../src/paths.js'),
|
||||
safe = require('safetydance');
|
||||
|
||||
exports.up = async function(db) {
|
||||
const backups = await db.runSql('SELECT format, COUNT(*) AS count FROM backups GROUP BY format WITH ROLLUP', []); // https://dev.mysql.com/doc/refman/8.4/en/group-by-modifiers.html
|
||||
@@ -39,7 +40,7 @@ exports.up = async function(db) {
|
||||
await db.runSql('ALTER TABLE backups ADD siteId VARCHAR(128)');
|
||||
if (totalCount) {
|
||||
if (currentBackupSite.format === 'tgz') {
|
||||
const ext = currentBackupSite.encryptionJson ? '.tar.gz.enc' : '.tar.gz';
|
||||
const ext = safe.JSON.parse(currentBackupSite.encryptionJson) ? '.tar.gz.enc' : '.tar.gz';
|
||||
console.log(`Adjusting remotePath of existing tgz backups with ${ext}`);
|
||||
await db.runSql('UPDATE backups SET remotePath=CONCAT(remotePath, ?) WHERE format=?', [ ext, 'tgz' ]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user