Skip to content

Commit

Permalink
Cast job to right type in retry
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Feb 18, 2025
1 parent eba787c commit 33bde5f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/btrixcloud/background_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ async def retry_org_background_job(
) -> Dict[str, Union[bool, Optional[str]]]:
"""Retry background job specific to one org"""
if job.type == BgJobType.CREATE_REPLICA:
job = cast(CreateReplicaJob, job)
file = await self.get_replica_job_file(job, org)
primary_storage = self.storage_ops.get_org_storage_by_ref(org, file.storage)
primary_endpoint, bucket_suffix = self.strip_bucket(
Expand All @@ -688,6 +689,7 @@ async def retry_org_background_job(
return {"success": True}

if job.type == BgJobType.DELETE_REPLICA:
job = cast(DeleteReplicaJob, job)
file = await self.get_replica_job_file(job, org)
await self.create_delete_replica_job(
org,
Expand All @@ -701,20 +703,23 @@ async def retry_org_background_job(
return {"success": True}

if job.type == BgJobType.DELETE_ORG:
job = cast(DeleteOrgJob, job)
await self.create_delete_org_job(
org,
existing_job_id=job.id,
)
return {"success": True}

if job.type == BgJobType.RECALCULATE_ORG_STATS:
job = cast(RecalculateOrgStatsJob, job)
await self.create_recalculate_org_stats_job(
org,
existing_job_id=job.id,
)
return {"success": True}

if job.type == BgJobType.READD_ORG_PAGES:
job = cast(ReAddOrgPagesJob, job)
await self.create_re_add_org_pages_job(
org.id,
job.crawl_type,
Expand Down

0 comments on commit 33bde5f

Please sign in to comment.