feat(restore): self-heal restore_allow_force default ON at boot
Fresh installs of picpeak had `restore_allow_force` defaulting to false (or missing entirely). Combined with the "1 active admin user" pre-restore warning that the fresh-install admin auto-creates, this meant the very first restore on every new install hit: Force restore is not allowed by system settings Admins then had to hand-craft SQL to flip the setting before they could recover their data — at the worst possible moment, when they were already mid-disaster. This isn't security: the admin who can SQL the setting on can also flip it via the UI. It's just a sharp edge that bites every new install once. Cure: boot-time self-heal that seeds restore_allow_force=true only when the row doesn't exist. Existing installs that explicitly set the row (true OR false) are NOT touched — admin policy wins. Pattern mirrors _backupPathsBoot.js and _emailTemplateBoot.js. Default-ON rationale matches Stage A's principle: the cost of forgetting (= can't recover from a disaster) outweighs the friction saved (= adversarial admins can't run forced restores). Audit logging keeps the accountability story intact.
This commit is contained in:
@@ -812,6 +812,18 @@ async function startServer() {
|
||||
logger.warn('backup_paths self-heal failed at boot:', err.message);
|
||||
}
|
||||
|
||||
// Self-heal restore-meta settings — currently just
|
||||
// `restore_allow_force` defaulting to ON so fresh installs can
|
||||
// recover from disaster without a SQL incantation. Only seeds on
|
||||
// FRESH installs (existing rows, true or false, are preserved).
|
||||
// See _restoreSettingsBoot.js for the full rationale.
|
||||
try {
|
||||
const { seedRestoreSettingsAtBoot } = require('./src/services/_restoreSettingsBoot');
|
||||
await seedRestoreSettingsAtBoot(db, logger);
|
||||
} catch (err) {
|
||||
logger.warn('restore-settings self-heal failed at boot:', err.message);
|
||||
}
|
||||
|
||||
// Start backup service
|
||||
await startBackupService();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user