File obs-server-2.10-0024-backend-Make-chekconstraints-in-repserver-not-fail-o.patch of Package obs-server

From 9861f7066f0baa076d28e2e8b4d6b6fe94386735 Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Mon, 15 Oct 2018 00:28:21 +0100
Subject: [PATCH] [backend] Make chekconstraints in repserver not fail on empty
 payload.

Sometimes frontend sends "/worker?cmd=checkconstraints" POST request
to srcserver with the following headers:

    Content-Type: application/octet-stream
    Content-Length: 0

This causes srcserver to pass empty payload to repserver
using chunked encoding, making it think that it has content
in request and failing to parse empty data received it as XML.

This change fixes this bug.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 src/backend/bs_repserver | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/bs_repserver b/src/backend/bs_repserver
index cbf63163bb..2f18d97750 100755
--- a/src/backend/bs_repserver
+++ b/src/backend/bs_repserver
@@ -4063,7 +4063,7 @@ sub checkconstraints {
     mkdir_p($uploaddir);
     my $uploaded = BSServer::read_file("$uploaddir/$$");
     die("upload failed\n") unless $uploaded;
-    $constraints = readxml("$uploaddir/$$", $BSXML::constraints);
+    $constraints = readxml("$uploaddir/$$", $BSXML::constraints) if $uploaded->{'size'} > 0;
     unlink("$uploaddir/$$");
   }
   my $pconf = BSRPC::rpc("$BSConfig::srcserver/getconfig", undef, "project=$projid", "repository=$repoid");
-- 
2.31.1