-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
fix: restore missing blob file when re-publishing a package #39239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bircni
merged 8 commits into
go-gitea:main
from
Huang-404-Q:fix/restore-missing-blob-file-39215
Sep 5, 2026
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
266d377
fix: restore missing blob file when re-publishing a package
Huang-404-Q 4590db1
simplify: drop util.ErrNotExist check that storage Has cannot return
Huang-404-Q 08e5619
refactor
wxiaoguang 3a1cd80
fix test
wxiaoguang ecdd61b
comment
wxiaoguang de566a0
Merge branch 'main' into fix/restore-missing-blob-file-39215
wxiaoguang d877ef5
fix
wxiaoguang c70a8e0
fine tune clean up
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review and fix this line by human.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. This line mirrors the check that already exists on the container registry path for the same inconsistency (the FIXME workaround for #19586 in
routers/api/packages/container/blob.go):The intent:
GetOrInsertBlobreturningexists=trueonly proves the row exists, not the file. When the file is missing (Hasreports not-exist), treat the blob as missing so theSavebelow rewrites it — otherwise, after a "row present, file lost" storage inconsistency, every re-publish of the same content inserts newpackage_filerows and never restores the file, and downloads fail forever (the failure mode in #39215).One deliberate choice to flag: if
Hasfails with any error other than not-exist (e.g. an I/O error), we keepexists=trueand skip theSave. That matches the container path exactly — a transient storage error should not silently turn into "file missing" and risk dropping the blob from further consideration; and in the common case (local file system, S3) a read error on an existing file is far less likely than a plain not-exist.Happy to adjust if you'd rather handle the error differently (e.g. propagate it, or treat any
Haserror as missing).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md#ai-contribution-policy
No time to read AI response.
Reply by human. Just tell people what's the right thing to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentStore.Hasonly returnsos.ErrNotExist, it never returnsutil.ErrNotExistOld code is not right either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4590db1 — you're right, the storage layer only ever returns os.ErrNotExist, so the util.ErrNotExist check was dead code. Dropped it, kept the os.ErrNotExist check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. I will try to refactor the legacy code together.