Skip to content

Commit

Permalink
fix(xo-web/backup): avoid 0 value for backup speed limit (#7980)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
b-Nollet committed Sep 13, 2024
1 parent 74e6fa2 commit 40f5f48
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/xo-web/src/xo-app/backup/new/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ const New = decorate([
}
}

if (settings[''].maxExportRate <= 0) {
settings[''].maxExportRate = undefined
}

await createBackupNgJob({
name: state.name,
mode: state.isDelta ? 'delta' : 'full',
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 40f5f48

Please sign in to comment.