From f995bcc87a9e693883292247ec985df7541d06bf Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 19 Apr 2017 13:09:49 +0200 Subject: Add repo mirror sync API endpoint (#1508) * API: Add repo mirror sync * Correct error message * Change http status to 200 --- routers/api/v1/repo/repo.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'routers/api/v1/repo') diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 317b0c57a1..0f22eaeb8f 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -269,3 +269,15 @@ func Delete(ctx *context.APIContext) { log.Trace("Repository deleted: %s/%s", owner.Name, repo.Name) ctx.Status(204) } + +// MirrorSync adds a mirrored repository to the sync queue +func MirrorSync(ctx *context.APIContext) { + repo := ctx.Repo.Repository + + if !ctx.Repo.IsWriter() { + ctx.Error(403, "MirrorSync", "Must have write access") + } + + go models.MirrorQueue.Add(repo.ID) + ctx.Status(200) +} -- cgit v1.2.3