Skip to content

Fix attachment download bug #27486

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
merged 7 commits into from
Oct 10, 2023
Merged

Conversation

lunny
Copy link
Member

@lunny lunny commented Oct 6, 2023

Fix #27204

This PR allows /<username>/<reponame>/attachments/<uuid> access with personal access token and also changed attachments API download url to it so it can be download correctly.

@lunny lunny added type/bug backport/v1.20 This PR should be backported to Gitea 1.20 backport/v1.21 This PR should be backported to Gitea 1.21 labels Oct 6, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 6, 2023
@@ -16,12 +13,7 @@ func WebAssetDownloadURL(repo *repo_model.Repository, attach *repo_model.Attachm
}

func APIAssetDownloadURL(repo *repo_model.Repository, attach *repo_model.Attachment) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need the repo param anymore now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these function could be removed. To keep this PR small, I need another refactor PR to do that.

@lunny lunny requested a review from delvh October 9, 2023 06:43
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 9, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 9, 2023
}

// /repos/{owner}/{repo}/releases/{id}/assets/{attachment_id}
return setting.AppURL + "api/repos/" + repo.FullName() + "/releases/" + strconv.FormatInt(attach.ReleaseID, 10) + "/assets/" + strconv.FormatInt(attach.ID, 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen to setting.AppURL + "api/repos/" + repo.FullName() + "/releases/" + strconv.FormatInt(attach.ReleaseID, 10) + "/assets/" + strconv.FormatInt(attach.ID, 10) ?

Should this handler be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it has been released, maybe deprecated is better.

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 10, 2023
@lunny lunny enabled auto-merge (squash) October 10, 2023 14:02
@lunny lunny merged commit 5c9fbcc into go-gitea:main Oct 10, 2023
@GiteaBot GiteaBot added this to the 1.22.0 milestone Oct 10, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 10, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Oct 10, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Oct 10, 2023
@lunny lunny deleted the lunny/fix_api_attach_url branch October 11, 2023 00:21
silverwind pushed a commit that referenced this pull request Oct 11, 2023
Backport #27486 by @lunny

Fix #27204

This PR allows `/<username>/<reponame>/attachments/<uuid>` access with
personal access token and also changed attachments API download url to
it so it can be download correctly.

Co-authored-by: Lunny Xiao <[email protected]>
silverwind pushed a commit that referenced this pull request Oct 11, 2023
Backport #27486 by @lunny

Fix #27204

This PR allows `/<username>/<reponame>/attachments/<uuid>` access with
personal access token and also changed attachments API download url to
it so it can be download correctly.

Co-authored-by: Lunny Xiao <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Oct 11, 2023
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Fix attachment download bug (go-gitea#27486)
  Make actions default enabled for newly created repository if global configuraion enabled (go-gitea#27482)
  Fix the wrong HTTP response status code for duplicate packages (go-gitea#27480)
  Increase queue length (go-gitea#27555)
@GiteaBot
Copy link
Collaborator

I was unable to create a backport for 1.20. @lunny, please send one manually. 🍵

go run ./contrib/backport 27486
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added the backport/manual No power to the bots! Create your backport yourself! label Oct 11, 2023
@GiteaBot
Copy link
Collaborator

I was unable to create a backport for 1.21. @lunny, please send one manually. 🍵

go run ./contrib/backport 27486
...  // fix git conflicts if any
go run ./contrib/backport --continue

@lunny lunny added the backport/done All backports for this PR have been created label Oct 11, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.20 This PR should be backported to Gitea 1.20 backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][API] Issue/pr attachments return wrong download url
5 participants