- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.2k
 
Fix removing some packages will result dirty data #34709
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
base: main
Are you sure you want to change the base?
Conversation
| 
           I don't think this is cleaner than my PR. With this change some package types must call the remove method from the router, other types must call the remove method from the service.  | 
    
          
 Your implementation will still have a chance to fail with dirty data. The   | 
    
| // DeletePackage deletes the specific generic package. | ||
| func DeletePackage(ctx *context.Context) { | ||
| err := packages_service.RemovePackageVersionByNameAndVersion( | ||
| err := common.RemovePackageVersionByNameAndVersion( | 
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.
Why the common is in "routers" package but not "services"?
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.
If you need to resolve the dependency problem, it should be something like services/packagemanager to manage all packages.
| 
               | 
          ||
| for _, pv := range pvs { | ||
| if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil { | ||
| if err := common.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil { | 
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.
It calls RemovePackageVersion mutiple times and "build" again and again. It doesn't seem right.
It should introduce a final step to rebuild when the removal finishes.
| 
           Don't backport since the design still has problems and no test.  | 
    
| 
           Simply removing packages by version may cause issues, as identical versions can contain files residing in different groups (refer to #26984), governed by  gitea/models/packages/package_file.go Line 40 in 04017f2 
 For instance, package  A real-world case:  BTW cleanup functionality is actually implemented twice in the codebase: This duplication may cause discrepancies between the preview results and actual execution outcomes.  | 
    
Fix #32830
Inspired by #22810 and replace it.
When deleting alphe, cargo, debian, rpm packages, some extra actions should be taken which was missed. It will result in dirty data and inconsistent. This PR fix it. To avoid recycle dependencies, this is a quick patch. Like #22810 (comment) said, this might need a new design for such more packages types.