fix(services): clean up dependent resources during service deletion

This commit is contained in:
2026-05-28 16:13:06 +00:00
parent 7f0c968b5c
commit 966c626d36
9 changed files with 691 additions and 8 deletions
@@ -198,6 +198,18 @@ export class CloudlyBackupManager {
return await backup.createSavableObject();
}
public async deleteBackupsForService(serviceIdArg: string): Promise<void> {
const backups = await this.CBackupRecord.getInstances({
serviceId: serviceIdArg,
});
for (const backup of backups) {
if (backup.replication?.targetPath) {
await this.getBackupTargetWriter().deletePrefix(backup.replication.targetPath);
}
await backup.delete();
}
}
public async backupAllServices() {
const services = await this.cloudlyRef.serviceManager.CService.getInstances({});
const results: Array<{ serviceId: string; backupId?: string; errorText?: string }> = [];