diff options
author | J0WI <J0WI@users.noreply.github.com> | 2021-04-13 01:17:28 +0200 |
---|---|---|
committer | J0WI <J0WI@users.noreply.github.com> | 2021-10-23 23:15:42 +0200 |
commit | 047cab8dd26d9c31c6a747499a06c80c7e29c37e (patch) | |
tree | 3c7b148601ce333e72cfb1960a3cd453d8ab0064 /lib/private/PreviewManager.php | |
parent | 623ac8c7066227d9bf499cd42ca7c8a27ecf4346 (diff) | |
download | nextcloud-server-047cab8dd26d9c31c6a747499a06c80c7e29c37e.tar.gz nextcloud-server-047cab8dd26d9c31c6a747499a06c80c7e29c37e.zip |
Use findBinaryPath for previews
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
Diffstat (limited to 'lib/private/PreviewManager.php')
-rw-r--r-- | lib/private/PreviewManager.php | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 02d017a5017..18d4427d346 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -417,41 +417,34 @@ class PreviewManager implements IPreview { } if (count($checkImagick->queryFormats('PDF')) === 1) { - if (\OC_Helper::is_function_enabled('shell_exec')) { - $officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null)); - - if (!$officeFound) { - //let's see if there is libreoffice or openoffice on this machine - $whichLibreOffice = shell_exec('command -v libreoffice'); - $officeFound = !empty($whichLibreOffice); - if (!$officeFound) { - $whichOpenOffice = shell_exec('command -v openoffice'); - $officeFound = !empty($whichOpenOffice); - } - } + // Office requires openoffice or libreoffice + $officeBinary = $this->config->getSystemValue('preview_libreoffice_path', null); + if (is_null($officeBinary)) { + $officeBinary = \OC_Helper::findBinaryPath('libreoffice'); + } + if (is_null($officeBinary)) { + $officeBinary = \OC_Helper::findBinaryPath('openoffice'); + } - if ($officeFound) { - $this->registerCoreProvider(Preview\MSOfficeDoc::class, '/application\/msword/'); - $this->registerCoreProvider(Preview\MSOffice2003::class, '/application\/vnd.ms-.*/'); - $this->registerCoreProvider(Preview\MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/'); - $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/'); - $this->registerCoreProvider(Preview\StarOffice::class, '/application\/vnd.sun.xml.*/'); - } + if (is_string($officeBinary)) { + $this->registerCoreProvider(Preview\MSOfficeDoc::class, '/application\/msword/', ["officeBinary" => $officeBinary]); + $this->registerCoreProvider(Preview\MSOffice2003::class, '/application\/vnd.ms-.*/', ["officeBinary" => $officeBinary]); + $this->registerCoreProvider(Preview\MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/', ["officeBinary" => $officeBinary]); + $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/', ["officeBinary" => $officeBinary]); + $this->registerCoreProvider(Preview\StarOffice::class, '/application\/vnd.sun.xml.*/', ["officeBinary" => $officeBinary]); } } } // Video requires avconv or ffmpeg if (in_array(Preview\Movie::class, $this->getEnabledDefaultProvider())) { - $avconvBinary = \OC_Helper::findBinaryPath('avconv'); - $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg'); - - if ($avconvBinary || $ffmpegBinary) { - // FIXME // a bit hacky but didn't want to use subclasses - \OC\Preview\Movie::$avconvBinary = $avconvBinary; - \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary; + $movieBinary = \OC_Helper::findBinaryPath('avconv'); + if (is_null($movieBinary)) { + $movieBinary = \OC_Helper::findBinaryPath('ffmpeg'); + } - $this->registerCoreProvider(Preview\Movie::class, '/video\/.*/'); + if (is_string($movieBinary)) { + $this->registerCoreProvider(Preview\Movie::class, '/video\/.*/', ["movieBinary" => $movieBinary]); } } } |