aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-05-14 12:45:25 +0200
committerGitHub <noreply@github.com>2025-05-14 12:45:25 +0200
commita01e85799c2d0f68a0833f1298e67ffbd24100be (patch)
treea5f7ed6ab908ccc0d7b6ff5b698bb44576e94b65
parent1950076ca1f4f87cb363577d85c188c07ab934cf (diff)
parent85a6b0d0ebcaf105b914184fdbca9a7c8ee04ab7 (diff)
downloadnextcloud-server-a01e85799c2d0f68a0833f1298e67ffbd24100be.tar.gz
nextcloud-server-a01e85799c2d0f68a0833f1298e67ffbd24100be.zip
Merge pull request #52802 from nextcloud/chore/oc-helper-can-exec
chore: deprecate \OC_Helper::canExecute
-rw-r--r--lib/private/Files/Type/Detection.php7
-rw-r--r--lib/private/legacy/OC_Helper.php1
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php
index 42315247dbf..aeaac030413 100644
--- a/lib/private/Files/Type/Detection.php
+++ b/lib/private/Files/Type/Detection.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OC\Files\Type;
use OCP\Files\IMimeTypeDetector;
+use OCP\IBinaryFinder;
use OCP\ITempManager;
use OCP\IURLGenerator;
use Psr\Log\LoggerInterface;
@@ -225,11 +226,13 @@ class Detection implements IMimeTypeDetector {
}
}
- if (\OC_Helper::canExecute('file')) {
+ $binaryFinder = \OCP\Server::get(IBinaryFinder::class);
+ $program = $binaryFinder->findBinaryPath('file');
+ if ($program !== false) {
// it looks like we have a 'file' command,
// lets see if it does have mime support
$path = escapeshellarg($path);
- $fp = popen("test -f $path && file -b --mime-type $path", 'r');
+ $fp = popen("test -f $path && $program -b --mime-type $path", 'r');
if ($fp !== false) {
$mimeType = fgets($fp);
pclose($fp);
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index a89cbe1bb3a..a9d5160ebe4 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -196,6 +196,7 @@ class OC_Helper {
* @internal param string $program name
* @internal param string $optional search path, defaults to $PATH
* @return bool true if executable program found in path
+ * @deprecated 32.0.0 use the \OCP\IBinaryFinder
*/
public static function canExecute($name, $path = false) {
// path defaults to PATH from environment if not set