Fix failure not being reported from API. #290

This commit is contained in:
Andrey Smirnov
2016-03-01 12:52:54 +03:00
parent a29453805c
commit 18d04c7977
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -142,6 +142,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList) {
nil, context.DependencyOptions(), architecturesList)
if err != nil {
c.Fail(500, fmt.Errorf("unable to search: %s", err))
return
}
}
+5
View File
@@ -205,6 +205,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
err = collection.Add(published)
if err != nil {
c.Fail(500, fmt.Errorf("unable to save to DB: %s", err))
return
}
c.JSON(201, published)
@@ -296,6 +297,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
}
} else {
c.Fail(500, fmt.Errorf("unknown published repository type"))
return
}
if b.SkipContents != nil {
@@ -305,17 +307,20 @@ func apiPublishUpdateSwitch(c *gin.Context) {
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite)
if err != nil {
c.Fail(500, fmt.Errorf("unable to update: %s", err))
return
}
err = collection.Update(published)
if err != nil {
c.Fail(500, fmt.Errorf("unable to save to DB: %s", err))
return
}
err = collection.CleanupPrefixComponentFiles(published.Prefix, updatedComponents,
context.GetPublishedStorage(storage), context.CollectionFactory(), nil)
if err != nil {
c.Fail(500, fmt.Errorf("unable to update: %s", err))
return
}
c.JSON(200, published)