mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
Someone looking at the target's directory could not tell whose backup a file was without opening its manifest. A new backup's files are named <vm>-<backup uuid>-<file> (the VM's name made safe for a file name, at most 64 characters). The prefix is kept on the row: backups made before keep their wvc-<uuid> names (migration 0007), and an import takes it from the manifest's file name. Manifests of either naming are found by their UUID suffix.
18 lines
697 B
Python
18 lines
697 B
Python
from django.db import migrations, models
|
|
|
|
|
|
def earlier_names(apps, schema_editor):
|
|
"""The backups made so far named their files from their UUID only."""
|
|
Backup = apps.get_model("vmbackups", "Backup")
|
|
for backup in Backup.objects.all():
|
|
Backup.objects.filter(pk=backup.pk).update(prefix=f"wvc-{backup.uuid}")
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [("vmbackups", "0006_run_note_messages")]
|
|
|
|
operations = [
|
|
migrations.AddField(model_name="backup", name="prefix", field=models.CharField(default="", max_length=128),
|
|
preserve_default=False),
|
|
migrations.RunPython(earlier_names, migrations.RunPython.noop),
|
|
]
|