From 40f5f48f172f0b5ce83814c83d8a562ba7d3558d Mon Sep 17 00:00:00 2001 From: b-Nollet <150058367+b-Nollet@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:25:35 +0200 Subject: [PATCH] fix(xo-web/backup): avoid 0 value for backup speed limit (#7980) Backup job's speed limit (`maxExportRate`) had values `0` and `undefined` leading to the same behaviour, but the values were both accepted, which could be confusing. 0 values are now replaced by `undefined` when creating or editing a backup job. --- .../xo-web/src/xo-app/backup/new/index.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/xo-web/src/xo-app/backup/new/index.js b/packages/xo-web/src/xo-app/backup/new/index.js index 16b6c2ba090..36acb3a4eb4 100644 --- a/packages/xo-web/src/xo-app/backup/new/index.js +++ b/packages/xo-web/src/xo-app/backup/new/index.js @@ -272,6 +272,10 @@ const New = decorate([ } } + if (settings[''].maxExportRate <= 0) { + settings[''].maxExportRate = undefined + } + await createBackupNgJob({ name: state.name, mode: state.isDelta ? 'delta' : 'full', @@ -338,19 +342,25 @@ const New = decorate([ }) ) + const normalizedSettings = normalizeSettings({ + offlineBackupActive: state.offlineBackupActive, + settings: settings || state.propSettings, + exportMode: state.exportMode, + copyMode: state.copyMode, + snapshotMode: state.snapshotMode, + }).toObject() + + if (normalizedSettings[''].maxExportRate <= 0) { + normalizedSettings[''].maxExportRate = undefined + } + await editBackupNgJob({ id: props.job.id, name: state.name, mode: state.isDelta ? 'delta' : 'full', compression: state.compression, proxy: state.proxyId, - settings: normalizeSettings({ - offlineBackupActive: state.offlineBackupActive, - settings: settings || state.propSettings, - exportMode: state.exportMode, - copyMode: state.copyMode, - snapshotMode: state.snapshotMode, - }).toObject(), + settings: normalizedSettings, remotes: state.deltaMode || state.backupMode ? constructPattern(state.remotes) : constructPattern([]), srs: state.crMode || state.drMode ? constructPattern(state.srs) : constructPattern([]), vms: state.smartMode ? state.vmsSmartPattern : constructPattern(state.vms),