Small fixes to publish update API. #174

This commit is contained in:
Andrey Smirnov
2015-02-07 19:01:06 +03:00
parent 4963d0a1d7
commit 24418ab0a4
+7 -2
View File
@@ -188,17 +188,22 @@ func apiPublishUpdateSwitch(c *gin.Context) {
return
}
// published.LoadComplete would touch local repo collection
localRepoCollection := context.CollectionFactory().LocalRepoCollection()
localRepoCollection.RLock()
defer localRepoCollection.RUnlock()
collection := context.CollectionFactory().PublishedRepoCollection()
collection.Lock()
defer collection.Unlock()
published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
if err != nil {
c.Fail(500, fmt.Errorf("unable to update: %s", err))
c.Fail(404, fmt.Errorf("unable to update: %s", err))
return
}
if published.SourceKind != "local" {
c.Fail(500, fmt.Errorf("unable to update: not a local repository"))
c.Fail(400, fmt.Errorf("unable to update: not a local repository"))
return
}