fix(subscriptions): don't crash when a project is already deleted
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2024-01-26 23:53:22 +01:00
parent 33a47b7f43
commit d38050f2b8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 9 additions and 0 deletions

View File

@ -266,6 +266,11 @@ func getSubscriptionsForProjects(s *xorm.Session, projectIDs []int64, u *user.Us
continue
}
ps[eID], err = GetProjectSimpleByID(s, eID)
if err != nil && IsErrProjectDoesNotExist(err) {
// If the project does not exist, it might got deleted. There could still be subscribers though.
delete(ps, eID)
continue
}
if err != nil {
return nil, err
}
@ -314,6 +319,10 @@ func getSubscriptionsForProjects(s *xorm.Session, projectIDs []int64, u *user.Us
_, has := projectsToSubscriptions[eID]
_, hasProject := ps[eID]
if !has && hasProject {
_, exists := ps[eID]
if !exists {
continue
}
var parent = ps[eID].ParentProject
for parent != nil {
sub, has := projectsToSubscriptions[parent.ID]