mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Memcache binary executable searching
It's slow, this makes it fast!
This commit is contained in:
parent
17dd5d0816
commit
c291383116
1 changed files with 8 additions and 2 deletions
|
|
@ -882,13 +882,19 @@ class OC_Helper {
|
|||
* @return null|string
|
||||
*/
|
||||
public static function findBinaryPath($program) {
|
||||
$memcache = \OC::$server->getMemCacheFactory()->create('findBinaryPath');
|
||||
if ($memcache->hasKey($program)) {
|
||||
return $memcache->get($program);
|
||||
}
|
||||
$result = null;
|
||||
if (!\OC_Util::runningOnWindows() && self::is_function_enabled('exec')) {
|
||||
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
||||
if ($returnCode === 0 && count($output) > 0) {
|
||||
return escapeshellcmd($output[0]);
|
||||
$result = escapeshellcmd($output[0]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
$memcache->set($program, $result, 3600);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue