fix(xo-web/backup/restore): dont fail if no backups for a VM (#5156)

Fixes xoa-support#2707

The API does not guarantee that each VM UUID will have at least a backup, and when it happens, the code failed because `first` and `last` where not properly defined.
This commit is contained in:
Julien Fontanet 2020-07-16 14:29:10 +02:00 committed by GitHub
parent 26a295c8ed
commit b74ec2d7d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,8 @@
> Users must be able to say: “I had this issue, happy to know it's fixed”
- [Backup/Restore] Fixes `an error has occurred` when all backups for a specific VM have been deleted (PR [#5156](https://github.com/vatesfr/xen-orchestra/pull/5156))
### Packages to release
> Packages will be released in the order they are here, therefore, they should
@ -27,3 +29,5 @@
> - major: if the change breaks compatibility
>
> In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-web patch

View File

@ -136,6 +136,10 @@ export default class Restore extends Component {
forEach(backupsByRemote, (backups, remoteId) => {
const remote = remotes[remoteId]
forEach(backups, (vmBackups, vmId) => {
if (vmBackups.length === 0) {
return
}
if (backupDataByVm[vmId] === undefined) {
backupDataByVm[vmId] = { backups: [] }
}