forked from mtusi2026/mtusi2026lab5
Preserve active staging and read published originals on reprocessing
This commit is contained in:
@@ -300,6 +300,12 @@ class PostgresAttachmentRepository:
|
||||
select(AttachmentRow.id, AttachmentRow.staging_key)
|
||||
.where(
|
||||
AttachmentRow.staging_key.is_not(None),
|
||||
~select(JobRow.job_id)
|
||||
.where(
|
||||
JobRow.attachment_id == AttachmentRow.id,
|
||||
JobRow.status.in_(["queued", "processing"]),
|
||||
)
|
||||
.exists(),
|
||||
or_(
|
||||
AttachmentRow.status == "ready",
|
||||
(AttachmentRow.status == "failed")
|
||||
@@ -566,12 +572,12 @@ class PostgresJobRepository:
|
||||
await self._note(claimed, "claimed")
|
||||
source = (
|
||||
await self._session.execute(
|
||||
select(AttachmentRow.staging_key, AttachmentRow.original_key).where(
|
||||
AttachmentRow.id == job.attachment_id
|
||||
)
|
||||
select(
|
||||
AttachmentRow.status, AttachmentRow.staging_key, AttachmentRow.original_key
|
||||
).where(AttachmentRow.id == job.attachment_id)
|
||||
)
|
||||
).one()
|
||||
staged = source.staging_key is not None
|
||||
staged = source.status != "ready" and source.staging_key is not None
|
||||
return Claim(
|
||||
Lease(claimed, token), source.staging_key if staged else source.original_key, staged
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user