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

From 11f464e37b205d50e160a5b57992173a47fe27b2 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 5352273094..afc7701fab 100755
--- a/src/backend/bs_repserver
+++ b/src/backend/bs_repserver
@@ -3805,7 +3805,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.20.1