fix(actions): preserve created_unix when re-uploading an expired artifact#38296
fix(actions): preserve created_unix when re-uploading an expired artifact#38296bircni wants to merge 2 commits into
Conversation
|
When and why a re-upload was allowed? |
On a rerun of a job... |
Wouldn’t there be a job attempt ID to prevent them from overriding each other? |
Reruns don't override each other — |
|
Actually I don't see the two problems on main branch.
The stale file can be deleted by gitea/routers/api/actions/artifacts_chunks.go Lines 379 to 386 in b09920a
|
When a workflow re-uploads an artifact whose previous content had already
expired (and whose storage blob was removed by the cleanup job),
CreateArtifactrevives the existing DB row as a fresh pending upload. This PR fixes two problems
in that path and adds test coverage.
1. Revive path resets status/storage but leaves stale content pointers
Previously, a matching row in a terminal state (
Expired/PendingDeletion/Deleted) was "revived" by only bumpingexpired_unix. That left the row stuckin its terminal status while still pointing at a
StoragePath/FileSizethat nolonger correspond to any content. A re-upload now reinitializes the row in place
as a brand-new
UploadPendingrecord (the unique index onrun_id/run_attempt_id/name/pathrequires updating the existing row rather thaninserting a second one).
2.
created_unixwas being clobbered on every re-uploadThe revive path returned a struct whose
CreatedUnixwas0. Both callers handthat returned struct straight to
UpdateArtifactByID, which usesAllCols()—so the zero value overwrote the row's original creation timestamp. The fix
carries
existing.CreatedUnixonto the returned struct so the subsequentAllCols()update preserves it.Why
Re-running a job after its artifact expired is a normal case. Without this fix
the artifact row keeps a dead status and stale storage pointers, and its
created_unixgets reset to "now" on every re-upload.