lab5: исправления второго ревью

Reprocess of a queued/processing/failed upload now sources from verified staging instead of the not-yet-written final original, which used to supersede v1 and strand the attachment in queued. PNG uploads now inflate the concatenated IDAT stream (bounded by IHDR dimensions) before acceptance, so a structurally valid PNG whose IDAT is not a zlib stream is rejected with 415 instead of 202.
This commit is contained in:
Vladislav Kunetskiy
2026-10-31 00:41:38 +03:00
parent ecdd91a15b
commit b965350cc9
13 changed files with 311 additions and 44 deletions
@@ -1338,9 +1338,24 @@ func (r *PipelineRepository) Reprocess(
return fmt.Errorf("%w: target pipeline version must be newer", domain.ErrConflict)
}
sourceKey := attachment.ObjectKey
if attachment.Status == domain.AttachmentPending {
return fmt.Errorf("%w: attachment upload is not complete", domain.ErrConflict)
}
// The verified upload lives in staging until the first pipeline
// publishes the final original. A queued/processing/failed attachment
// must reprocess from staging: object_key points at a final original
// that may not exist yet (worker stopped before the first run), and
// choosing it would supersede v1 and leave the attachment queued with
// no jobs after v2 fails with source_missing.
sourceKey := attachment.StagingKey
if attachment.Status == domain.AttachmentReady {
// Ready means the final original was published; staging may have
// passed its retention window already.
sourceKey = attachment.ObjectKey
}
if sourceKey == "" {
sourceKey = attachment.StagingKey
sourceKey = attachment.ObjectKey
}
if sourceKey == "" {
return fmt.Errorf("%w: attachment has no source object", domain.ErrConflict)