mirror of
https://github.com/nextcloud/app_api.git
synced 2025-07-23 04:49:13 +00:00
Fix parameter preparation for occ command
* Fix for #517 Signed-off-by: Robin Windey <ro.windey@gmail.com>
This commit is contained in:
@ -116,7 +116,7 @@ class ExAppArchiveFetcher {
|
||||
}
|
||||
|
||||
public function removeExAppFolder(string $appId): void {
|
||||
foreach ($this->config->getSystemValue('apps_paths') as $appPath) {
|
||||
foreach ($this->config->getSystemValue('apps_paths', []) as $appPath) {
|
||||
if ($appPath['writable']) {
|
||||
if (file_exists($appPath['path'] . '/' . $appId)) {
|
||||
$this->rmdirr($appPath['path'] . '/' . $appId);
|
||||
|
@ -428,8 +428,9 @@ class AppAPIService {
|
||||
*/
|
||||
public function runOccCommand(string $command): bool {
|
||||
$args = array_map(function ($arg) {
|
||||
return escapeshellarg($arg);
|
||||
return $arg === '' ? null : escapeshellarg($arg);
|
||||
}, explode(' ', $command));
|
||||
$args = array_filter($args, fn ($arg) => $arg !== null);
|
||||
$args[] = '--no-ansi --no-warnings';
|
||||
return $this->runOccCommandInternal($args);
|
||||
}
|
||||
@ -447,13 +448,28 @@ class AppAPIService {
|
||||
}
|
||||
$this->logger->info(sprintf('Calling occ(directory=%s): %s', $occDirectory ?? 'null', $args));
|
||||
$process = proc_open('php console.php ' . $args, $descriptors, $pipes, $occDirectory);
|
||||
|
||||
if (!is_resource($process)) {
|
||||
$this->logger->error(sprintf('Error calling occ(directory=%s): %s', $occDirectory ?? 'null', $args));
|
||||
return false;
|
||||
}
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]);
|
||||
|
||||
fclose($pipes[0]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
|
||||
$returnCode = proc_close($process);
|
||||
|
||||
if ($returnCode !== 0) {
|
||||
$this->logger->error(sprintf('Error executing occ command. Return code: %d, stdout: %s, stderr: %s', $returnCode, $stdout, $stderr));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->logger->info(sprintf('OCC command executed successfully. stdout: %s, stderr: %s', $stdout, $stderr));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user