Fix some annoying segfaults
This commit is contained in:
parent
dbc3eb7fa0
commit
3b547c695e
2
go.mod
2
go.mod
|
@ -35,7 +35,7 @@ require (
|
|||
github.com/felixge/fgprof v0.9.3
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/gliderlabs/ssh v0.3.5
|
||||
github.com/go-ap/activitypub v0.0.0-20230218112952-bfb607b04799
|
||||
github.com/go-ap/activitypub v0.0.0-20230307141717-3566110d71a0
|
||||
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
|
||||
github.com/go-chi/chi/v5 v5.0.8
|
||||
github.com/go-chi/cors v1.2.1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -352,8 +352,8 @@ github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
|
|||
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
|
||||
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
|
||||
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
|
||||
github.com/go-ap/activitypub v0.0.0-20230218112952-bfb607b04799 h1:zVZaYt1h4yWL7uRHvq2StewCu4ObtS+ws9gGgoZJ+2s=
|
||||
github.com/go-ap/activitypub v0.0.0-20230218112952-bfb607b04799/go.mod h1:1oVD0h0aPT3OEE1ZoSUoym/UGKzxe+e0y8K2AkQ1Hqs=
|
||||
github.com/go-ap/activitypub v0.0.0-20230307141717-3566110d71a0 h1:ll+jcwBW55vQDUV3jHuua/0wqjTm2GIh/iP1wwjbPSc=
|
||||
github.com/go-ap/activitypub v0.0.0-20230307141717-3566110d71a0/go.mod h1:1oVD0h0aPT3OEE1ZoSUoym/UGKzxe+e0y8K2AkQ1Hqs=
|
||||
github.com/go-ap/errors v0.0.0-20221205040414-01c1adfc98ea h1:ywGtLGVjJjMrq4mu35Qmu+NtlhlTk/gTayE6Bb4tQZk=
|
||||
github.com/go-ap/errors v0.0.0-20221205040414-01c1adfc98ea/go.mod h1:SaTNjEEkp0q+w3pUS1ccyEL/lUrHteORlDq/e21mCc8=
|
||||
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73 h1:GMKIYXyXPGIp+hYiWOhfqK4A023HdgisDT4YGgf99mw=
|
||||
|
|
|
@ -119,7 +119,7 @@ func createPersonFromIRI(ctx context.Context, personIRI ap.IRI) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ap.On(object, func(p *ap.Person) error {
|
||||
return ap.OnActor(object, func(p *ap.Person) error {
|
||||
return createPerson(ctx, p)
|
||||
})
|
||||
}
|
||||
|
@ -128,16 +128,21 @@ func createPersonFromIRI(ctx context.Context, personIRI ap.IRI) error {
|
|||
func createRepository(ctx context.Context, repository *forgefed.Repository) error {
|
||||
user, err := user_model.GetUserByIRI(ctx, repository.AttributedTo.GetLink().String())
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
// TODO: This should probably return the created user too
|
||||
err := createPersonFromIRI(ctx, repository.AttributedTo.GetLink())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user, err = user_model.GetUserByIRI(ctx, repository.AttributedTo.GetLink().String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check if repo exists
|
||||
_, err = repo_model.GetRepositoryByOwnerAndName(ctx, user.Name, repository.Name.String())
|
||||
_, err = repo_model.GetRepositoryByIRI(ctx, repository.GetLink().String())
|
||||
if !repo_model.IsErrRepoNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
|
Reference in a new issue