Commit 5b97dadd authored by Mark Harding's avatar Mark Harding
Browse files

(fix): only fire notifications when all transcodes have reached a state

parent bf6f144e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ class TranscodeStates
            'guid' => $video->getGuid(),
        ]);

        $total = 0;
        $created = 0;
        $failures = 0;
        $completed = 0;
@@ -48,6 +49,7 @@ class TranscodeStates
            if ($transcode instanceof TranscodeProfiles\Thumbnails) {
                continue; // We skip thumbnails as these are likely to succeed
            }
            ++$total;
            switch ($transcode->getStatus()) {
                case TranscodeStates::TRANSCODING:
                    if ($transcode->getLastEventTimestampMs() >= (time() - Manager::TRANSCODER_TIMEOUT_SECS) * 1000) {
@@ -75,6 +77,10 @@ class TranscodeStates
            return TranscodeStates::CREATED;
        }

        if ($total < ($completed + $failures)) {
            return TranscodeStates::CREATED;
        }

        // If we have more completions then failures the declare completed
        if ($failures < $completed) {
            return TranscodeStates::COMPLETED;