41 lines
949 B
PHP
41 lines
949 B
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Быстрая индексация одного файла в Nextcloud
|
||
|
|
*/
|
||
|
|
|
||
|
|
header('Content-Type: application/json');
|
||
|
|
|
||
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
||
|
|
$path = $input['path'] ?? '';
|
||
|
|
|
||
|
|
if (empty($path)) {
|
||
|
|
echo json_encode(['success' => false, 'error' => 'Missing path']);
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Формируем Nextcloud путь
|
||
|
|
$ncPath = '/admin/files/crm/' . $path;
|
||
|
|
|
||
|
|
// Запускаем сканирование
|
||
|
|
$command = "docker exec -u www-data nextcloud-fresh php occ files:scan --path=" . escapeshellarg($ncPath) . " 2>&1";
|
||
|
|
|
||
|
|
exec($command, $output, $returnCode);
|
||
|
|
|
||
|
|
if ($returnCode === 0) {
|
||
|
|
echo json_encode([
|
||
|
|
'success' => true,
|
||
|
|
'message' => 'File indexed successfully',
|
||
|
|
'output' => implode("\n", $output)
|
||
|
|
]);
|
||
|
|
} else {
|
||
|
|
echo json_encode([
|
||
|
|
'success' => false,
|
||
|
|
'error' => 'Indexing failed',
|
||
|
|
'output' => implode("\n", $output)
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
|
||
|
|
|
||
|
|
|