From ad393440ddda202000927a19910a19d7729ebdc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Mon, 25 Oct 2021 18:19:09 +0200
Subject: [PATCH] Zmena logiky nahravani

---
 .gitlab-ci.yml                 |  2 +-
 lib/PiTube/Controller/Nginx.pm | 47 +++++++++++++++++++---------------
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3dfe9d5..d3f8fed 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: docker:19.03.12
 
 variables:
   DOCKER_TLS_CERTDIR: "/certs"
-  IMAGE_VER: 2.0.0
+  IMAGE_VER: 2.0.1
 
 services:
   - docker:19.03.12-dind
diff --git a/lib/PiTube/Controller/Nginx.pm b/lib/PiTube/Controller/Nginx.pm
index c31cb29..fe24a15 100644
--- a/lib/PiTube/Controller/Nginx.pm
+++ b/lib/PiTube/Controller/Nginx.pm
@@ -68,27 +68,34 @@ sub callback_recorder($c) {
     $c->render( status => 404, text => '' ), return if ! $stream;
 
     # aktualizace stavu streamu
-    $stream->update({
-        recording     => 'f',
-    });
-
-    my $record = $stream->records(
-        {
-            end  => undef,
-            path => undef,
-        },
-        {
-            order_by => {'-desc' => 'begin'}
-        }
-    )->first;
+#    $stream->update({
+#        recording     => 'f',
+#    });
+#
+#    my $record = $stream->records(
+#        {
+#            end  => undef,
+#            path => undef,
+#        },
+#        {
+#            order_by => {'-desc' => 'begin'}
+#        }
+#    )->first;
+#
+#    if ( $record ) {
+#        $record->update({
+#            path     => $c->param('path'),
+#            recorder => $c->param('recorder'),
+#            end      => \'now()',
+#        });
+#    }
 
-    if ( $record ) {
-        $record->update({
-            path     => $c->param('path'),
-            recorder => $c->param('recorder'),
-            end      => \'now()',
-        });
-    }
+    $stream->add_to_records({
+        publish_user_id => $stream->publish_user_id,
+        path     => $c->param('path'),
+        recorder => $c->param('recorder'),
+        end      => \'now()',
+    });
 
     $c->render( status => 204, text => '' );
 }
-- 
GitLab