|
|
@ -5,6 +5,7 @@ package conan
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
std_ctx "context"
|
|
|
|
std_ctx "context"
|
|
|
|
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
@ -183,7 +184,7 @@ func serveSnapshot(ctx *context.Context, fileKey string) {
|
|
|
|
|
|
|
|
|
|
|
|
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeConan, rref.Name, rref.Version)
|
|
|
|
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeConan, rref.Name, rref.Version)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -244,7 +245,7 @@ func serveDownloadURLs(ctx *context.Context, fileKey, downloadURL string) {
|
|
|
|
|
|
|
|
|
|
|
|
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeConan, rref.Name, rref.Version)
|
|
|
|
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeConan, rref.Name, rref.Version)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -493,7 +494,7 @@ func downloadFile(ctx *context.Context, fileFilter container.Set[string], fileKe
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist || err == packages_model.ErrPackageFileNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, packages_model.ErrPackageFileNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -509,7 +510,7 @@ func DeleteRecipeV1(ctx *context.Context) {
|
|
|
|
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
|
|
|
|
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
|
|
|
|
|
|
|
|
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, true, nil, false); err != nil {
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, true, nil, false); err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -524,7 +525,7 @@ func DeleteRecipeV2(ctx *context.Context) {
|
|
|
|
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
|
|
|
|
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
|
|
|
|
|
|
|
|
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, rref.Revision == "", nil, false); err != nil {
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, rref.Revision == "", nil, false); err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -571,7 +572,7 @@ func DeletePackageV1(ctx *context.Context) {
|
|
|
|
for _, reference := range references {
|
|
|
|
for _, reference := range references {
|
|
|
|
pref, _ := conan_module.NewPackageReference(currentRref, reference.Value, conan_module.DefaultRevision)
|
|
|
|
pref, _ := conan_module.NewPackageReference(currentRref, reference.Value, conan_module.DefaultRevision)
|
|
|
|
if err := deleteRecipeOrPackage(ctx, currentRref, true, pref, true); err != nil {
|
|
|
|
if err := deleteRecipeOrPackage(ctx, currentRref, true, pref, true); err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -590,7 +591,7 @@ func DeletePackageV2(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
if pref != nil { // has package reference
|
|
|
|
if pref != nil { // has package reference
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, false, pref, pref.Revision == ""); err != nil {
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, false, pref, pref.Revision == ""); err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -615,7 +616,7 @@ func DeletePackageV2(ctx *context.Context) {
|
|
|
|
pref, _ := conan_module.NewPackageReference(rref, reference.Value, conan_module.DefaultRevision)
|
|
|
|
pref, _ := conan_module.NewPackageReference(rref, reference.Value, conan_module.DefaultRevision)
|
|
|
|
|
|
|
|
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, false, pref, true); err != nil {
|
|
|
|
if err := deleteRecipeOrPackage(ctx, rref, false, pref, true); err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -749,7 +750,7 @@ func LatestRecipeRevision(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
revision, err := conan_model.GetLastRecipeRevision(ctx, ctx.Package.Owner.ID, rref)
|
|
|
|
revision, err := conan_model.GetLastRecipeRevision(ctx, ctx.Package.Owner.ID, rref)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == conan_model.ErrRecipeReferenceNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, conan_model.ErrRecipeReferenceNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -766,7 +767,7 @@ func LatestPackageRevision(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
revision, err := conan_model.GetLastPackageRevision(ctx, ctx.Package.Owner.ID, pref)
|
|
|
|
revision, err := conan_model.GetLastPackageRevision(ctx, ctx.Package.Owner.ID, pref)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == conan_model.ErrRecipeReferenceNotExist || err == conan_model.ErrPackageReferenceNotExist {
|
|
|
|
if errors.Is(err, conan_model.ErrRecipeReferenceNotExist) || errors.Is(err, conan_model.ErrPackageReferenceNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
@ -796,7 +797,7 @@ func listRevisionFiles(ctx *context.Context, fileKey string) {
|
|
|
|
|
|
|
|
|
|
|
|
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeConan, rref.Name, rref.Version)
|
|
|
|
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeConan, rref.Name, rref.Version)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err == packages_model.ErrPackageNotExist {
|
|
|
|
if errors.Is(err, packages_model.ErrPackageNotExist) {
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
apiError(ctx, http.StatusNotFound, err)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|
apiError(ctx, http.StatusInternalServerError, err)
|
|
|
|