fix(restore): allow backups of any size

- default BACKUP_UPLOAD_LIMIT_MB to 0 (no hard cap, disk is the limit);
  a positive value still enables multer fileSize
- scale request timeout by the configured limit and keep up to 24h when
  unlimited, cap headersTimeout at 120s
- check Content-Length and free space before upload (413/507) and map
  multer ENOSPC to 507
- drop the hardcoded 500 MB fallback in the settings restore pre-check
- cover new limit/timeout helpers in backup.selftest.js
- update env template, compose, README, AGENTS and API docs
This commit is contained in:
dev
2026-10-21 18:13:24 +03:00
parent 19f63a4064
commit 697aac9b87
9 changed files with 106 additions and 25 deletions
+14
View File
@@ -7,6 +7,10 @@ const {
isSafeUploadPath,
normalizeRestoreData,
} = require('./backup-restore');
const {
parseBackupLimitMb,
backupRequestTimeoutMs,
} = require('./lib/restore');
let failed = 0;
function ok(label, cond, extra) {
@@ -26,6 +30,16 @@ ok('формат из будущего отклоняется', !isSupportedBack
ok('без groups отклоняется', !isSupportedBackupVersion({ version: BACKUP_FORMAT_VERSION }));
ok('не объект отклоняется', !isSupportedBackupVersion(null));
ok('BACKUP_UPLOAD_LIMIT_MB: пусто и 0 — без ограничения',
parseBackupLimitMb('') === 0 && parseBackupLimitMb('0') === 0 && parseBackupLimitMb(undefined) === 0);
ok('BACKUP_UPLOAD_LIMIT_MB: число сохраняется', parseBackupLimitMb('4096') === 4096);
ok('backupRequestTimeoutMs: без лимита — 24 часа',
backupRequestTimeoutMs({ limitMb: 0, uploadTimeoutMs: 1500000 }) === 86400000);
ok('backupRequestTimeoutMs: лимит растягивает таймаут',
backupRequestTimeoutMs({ limitMb: 4096, uploadTimeoutMs: 1500000 }) === 30720000);
ok('backupRequestTimeoutMs: явный таймаут важнее',
backupRequestTimeoutMs({ limitMb: 4096, uploadTimeoutMs: 1500000, explicitMs: '600000' }) === 600000);
ok('в бэкап входят audit_log/notifications/banned_ips',
['audit_log', 'notifications', 'notification_reads', 'banned_ips'].every(t => BACKUP_TABLES.includes(t)),
BACKUP_TABLES);