Skip to content

Delete unreferenced packages when deleting a package version#20977

Merged
zeripath merged 5 commits into
go-gitea:mainfrom
KN4CK3R:fix-20969
Sep 3, 2022
Merged

Delete unreferenced packages when deleting a package version#20977
zeripath merged 5 commits into
go-gitea:mainfrom
KN4CK3R:fix-20969

Conversation

@KN4CK3R

@KN4CK3R KN4CK3R commented Aug 27, 2022

Copy link
Copy Markdown
Member

Delete a package if its last version got deleted. Otherwise removing the owner works only after the clean up job ran.

Fix #20969

Comment thread services/packages/packages.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this is essentially doing a lot of the work that is in cleanup on every delete? i.e. it's tantamount to calling CleanUp for every delete?

Cant we use the information in pv to limit our unreferenced check to that particular package?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's not really much work. In the best case it's 1 sql query, average case is 1+2 queries and the worst case is 1+n*2 queries.

Anyway I just changed the definition of HasOwnerPackages, so no additional work to do.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 27, 2022
@lafriks

lafriks commented Aug 28, 2022

Copy link
Copy Markdown
Member

But it would still leave invalid user id referenced as owner?

@KN4CK3R

KN4CK3R commented Aug 28, 2022

Copy link
Copy Markdown
Member Author

Yes and they get cleaned up the next time the job runs.

@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 Sep 3, 2022
@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 Sep 3, 2022
Comment thread models/packages/package_test.go Outdated
@zeripath zeripath merged commit 5bc73ca into go-gitea:main Sep 3, 2022
@zeripath

zeripath commented Sep 3, 2022

Copy link
Copy Markdown
Contributor

Please send backport

zeripath pushed a commit to zeripath/gitea that referenced this pull request Sep 4, 2022
…a#20977)

Backport go-gitea#20977

Delete a package if its last version got deleted. Otherwise removing the owner works only after the clean up job ran.

Fix go-gitea#20969
@zeripath zeripath added the backport/done All backports for this PR have been created label Sep 4, 2022
techknowlogick pushed a commit that referenced this pull request Sep 4, 2022
…#21060)

Backport #20977

Delete a package if its last version got deleted. Otherwise removing the owner works only after the clean up job ran.

Fix #20969

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 5, 2022
* upstream/main: (22 commits)
  [skip ci] Updated translations via Crowdin
  Webhook for Wiki changes (go-gitea#20219)
  test: use `T.TempDir` to create temporary test directory (go-gitea#21043)
  Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (go-gitea#20902)
  Fix 500 on time tracking in timeline API (go-gitea#21052)
  Add more checks in migration code (go-gitea#21011)
  Fill the specified ref in webhook test payload (go-gitea#20961)
  [skip ci] Updated licenses and gitignores
  Add go licenses to licenses.txt (go-gitea#21034)
  Added docs for agit-setup (go-gitea#21027)
  Add another index for Action table on postgres (go-gitea#21033)
  Delete unreferenced packages when deleting a package version (go-gitea#20977)
  Improve arc-green code theme (go-gitea#21039)
  Add down key check has tribute container (go-gitea#21016)
  Do not add links to Posters or Assignees with ID < 0 (go-gitea#20577)
  [skip ci] Updated translations via Crowdin
  Show language name on hover (go-gitea#20923)
  fix: PackageMetadataVersion deps (go-gitea#21017)
  Fix the quick-submit for pending review comment (go-gitea#20992)
  Kd/ci playwright go test (go-gitea#20123)
  ...
@KN4CK3R KN4CK3R deleted the fix-20969 branch September 6, 2022 19:19
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
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 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/packages type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleted all packages, still failed to delete the account

6 participants