BackupManager: Remove backup fallback logic

This commit is contained in:
mikiher 2025-12-01 18:54:43 +02:00
parent 5f1edcb609
commit d7bfccdc4a

View file

@ -48,13 +48,6 @@ class BackupManager {
} }
async init() { async init() {
// Validate backupPath before attempting to create it
if (!this.backupPath || typeof this.backupPath !== 'string' || this.backupPath.length < 2) {
Logger.error(`[BackupManager] Invalid backup path configured: "${this.backupPath}". Falling back to default.`)
// Reset to default backup path
global.ServerSettings.backupPath = Path.join(global.MetadataPath, 'backups')
}
try { try {
const backupsDirExists = await fs.pathExists(this.backupPath) const backupsDirExists = await fs.pathExists(this.backupPath)
if (!backupsDirExists) { if (!backupsDirExists) {
@ -62,20 +55,7 @@ class BackupManager {
} }
} catch (error) { } catch (error) {
Logger.error(`[BackupManager] Failed to ensure backup directory at "${this.backupPath}": ${error.message}`) Logger.error(`[BackupManager] Failed to ensure backup directory at "${this.backupPath}": ${error.message}`)
// Attempt to fall back to default path throw new Error(`[BackupManager] Failed to ensure backup directory at "${this.backupPath}"`, { cause: error })
const defaultBackupPath = Path.join(global.MetadataPath, 'backups')
if (this.backupPath !== defaultBackupPath) {
Logger.info(`[BackupManager] Attempting to use default backup path: "${defaultBackupPath}"`)
global.ServerSettings.backupPath = defaultBackupPath
try {
await fs.ensureDir(defaultBackupPath)
} catch (fallbackError) {
Logger.error(`[BackupManager] Failed to create default backup directory: ${fallbackError.message}`)
throw new Error(`[BackupManager] Failed to create default backup directory at "${defaultBackupPath}"`, { cause: fallbackError })
}
} else {
throw new Error(`[BackupManager] Failed to ensure backup directory at "${this.backupPath}"`, { cause: error })
}
} }
await this.loadBackups() await this.loadBackups()