From 24418ab0a4409ae68003837623bcef541eda7846 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sat, 7 Feb 2015 19:01:06 +0300 Subject: [PATCH] Small fixes to publish update API. #174 --- api/publish.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/publish.go b/api/publish.go index 07344d3d..5abb6721 100644 --- a/api/publish.go +++ b/api/publish.go @@ -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 }