video: use guardExDirect for transcode
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/602/head
parent
67fccd0799
commit
9ae10a68f1
|
@ -25,6 +25,7 @@ namespace OCA\Memories\Controller;
|
|||
|
||||
use OCA\Memories\Exceptions;
|
||||
use OCA\Memories\Exif;
|
||||
use OCA\Memories\HttpResponseException;
|
||||
use OCA\Memories\Service\BinExt;
|
||||
use OCA\Memories\Util;
|
||||
use OCP\AppFramework\Http;
|
||||
|
@ -77,24 +78,29 @@ class VideoController extends GenericApiController
|
|||
}
|
||||
|
||||
// Request and check data was received
|
||||
return Util::guardExDirect(function ($out) use ($client, $path, $profile) {
|
||||
try {
|
||||
$status = $this->getUpstream($client, $path, $profile);
|
||||
if (409 === $status || -1 === $status) {
|
||||
// Just a conflict (transcoding process changed)
|
||||
return new JSONResponse(['message' => 'Conflict'], Http::STATUS_CONFLICT);
|
||||
$response = new JSONResponse(['message' => 'Conflict'], Http::STATUS_CONFLICT);
|
||||
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
if (200 !== $status) {
|
||||
throw new \Exception("Transcoder returned {$status}");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$msg = 'Transcode failed: '.$e->getMessage();
|
||||
$this->logger->error($msg, ['app' => 'memories']);
|
||||
if ($e instanceof HttpResponseException && Http::STATUS_CONFLICT === $e->response->getStatus()) {
|
||||
throw $e; // Logging this is noise
|
||||
}
|
||||
|
||||
// We cannot show this error in the user interface, so log it
|
||||
$this->logger->error('Transcode failed: '.$e->getMessage(), ['app' => 'memories']);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// The response was already streamed, so we have nothing to do here
|
||||
exit;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue