Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : dist-git
---------------------------------------------------------------
commit c717eb50f16d0ebdabf36e4dfbe3018e06f85bad
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Wed Jun 24 17:46:00 2015 +0200
dist git update view in backend_ns
---------------------------------------------------------------
frontend/coprs_frontend/coprs/models.py | 4 +++
.../coprs/views/backend_ns/backend_general.py | 29 ++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/models.py
b/frontend/coprs_frontend/coprs/models.py
index 16e4800..53a3270 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -338,6 +338,10 @@ class Build(db.Model, helpers.Serializer):
helpers.StatusEnum("running") in self.chroot_states
@property
+ def has_uploading_chroot(self):
+ return helpers.StatusEnum("uploading") in self.chroot_states
+
+ @property
def status(self):
"""
Return build status according to build status of its chroots
diff --git a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
index 26800bf..420cd90 100644
--- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
+++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
@@ -41,6 +41,35 @@ def dist_git_uploading_queue():
return flask.jsonify(response_dict)
+(a)backend_ns.route("/upload-completed/", methods=["POST",
"PUT"])
+(a)misc.backend_authenticated
+def dist_git_upload_completed():
+ """
+ Mark BuildChroot in a Build as uploaded, which means:
+ - set it to pending state
+ - set BuildChroot.git_hash
+ - if it's the last BuildChroot in a Build, delete local srpm
+ BuildChroot is identified with task_id which is build id + git branch name
+ - For example: 56-f22 -> build 55, chroots fedora-22-*
+ """
+ result = {"updated": False}
+
+ if "task_id" in flask.request.json and "git_hash" in
flask.request.json:
+ task_id = flask.request.json["task_id"]
+ git_hash = flask.request.json["git_hash"]
+ build_chroots = BuildsLogic.get_chroots_from_dist_git_task_id(task_id)
+ for ch in build_chroots:
+ ch.status = helpers.StatusEnum("pending")
+ ch.git_hash = git_hash
+
+ build = build_chroots[0].build
+ if not build.has_uploading_chroot():
+ BuildsLogic.delete_local_srpm(build)
+
+ result["updated"] = True
+
+ return result
+
@backend_ns.route("/waiting/")
@misc.backend_authenticated
def waiting():