1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(vmbackups): seventh audit: files of a VM named after a backup, restore-over page

- A VM may be named "<another backup's prefix>-x": its backups' files then
  begin with that prefix too, and deleting the other backup removed them.
  Backup.owns() takes a file only when no other backup UUID follows the
  prefix; deletion and the storage pages' refusal use it.
- The restore-over page failed with a server error when the VM's pool
  could not be read while naming the copies; it now says why.
This commit is contained in:
catborise 2026-11-18 15:33:30 +03:00
parent 5b05e76ebc
commit 348628f13d
6 changed files with 36 additions and 3 deletions

View file

@ -23,7 +23,7 @@ def inside_vm_pool(conn, pool):
def refuse_backup_volume(compute, pool, volume):
"""A volume of a backup is deleted with its backup, on the Backups pages."""
for backup in Backup.objects.filter(target__pools__compute=compute, target__pools__pool=pool):
if volume.startswith(backup.prefix + "-"):
if backup.owns(volume):
raise InUse(
gettext_noop("Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the Backups page"),
volume=volume,