nextcloud connessione ok gdrive no
This commit is contained in:
@@ -18,6 +18,12 @@ class StorageRepositoryService
|
||||
{
|
||||
try {
|
||||
$config = $repo->getDecryptedConfig();
|
||||
// Log only the keys of the config (avoid sensitive values)
|
||||
try {
|
||||
Log::debug("StorageRepository: config keys for repo #{$repo->id}: " . json_encode(array_keys($config)));
|
||||
} catch (\Exception) {
|
||||
// ignore logging errors
|
||||
}
|
||||
|
||||
return match ($repo->tipo) {
|
||||
'webdav' => $this->buildWebDAV($config),
|
||||
@@ -76,16 +82,27 @@ class StorageRepositoryService
|
||||
$items = $filesystem->listContents($normalizedPath, false)->toArray();
|
||||
$result = [];
|
||||
foreach ($items as $item) {
|
||||
$path = method_exists($item, 'path') ? $item->path() : (is_array($item) && isset($item['path']) ? $item['path'] : null);
|
||||
$type = method_exists($item, 'type') ? $item->type() : (is_array($item) && isset($item['type']) ? $item['type'] : null);
|
||||
$basename = $path ? basename($path) : '';
|
||||
$lastModified = method_exists($item, 'lastModified') ? $item->lastModified() : (is_array($item) && isset($item['lastmodified']) ? $item['lastmodified'] : null);
|
||||
$fileSize = method_exists($item, 'fileSize') ? $item->fileSize() : (is_array($item) && isset($item['filesize']) ? $item['filesize'] : null);
|
||||
$mimeType = method_exists($item, 'mimeType') ? $item->mimeType() : (is_array($item) && isset($item['mimetype']) ? $item['mimetype'] : null);
|
||||
|
||||
$result[] = [
|
||||
'path' => $item->path(),
|
||||
'type' => $item->type(),
|
||||
'basename' => basename($item->path()),
|
||||
'lastModified' => $item->lastModified(),
|
||||
'fileSize' => $item->fileSize(),
|
||||
'mimeType' => $item->mimeType(),
|
||||
'path' => $path,
|
||||
'type' => $type,
|
||||
'basename' => $basename,
|
||||
'lastModified' => $lastModified,
|
||||
'fileSize' => $fileSize,
|
||||
'mimeType' => $mimeType,
|
||||
];
|
||||
}
|
||||
usort($result, fn($a, $b) => $a['type'] === 'dir' && $b['type'] !== 'dir' ? -1 : ($b['type'] === 'dir' && $a['type'] !== 'dir' ? 1 : strcasecmp($a['basename'], $b['basename'])));
|
||||
|
||||
usort($result, fn($a, $b) => ($a['type'] === 'dir' && $b['type'] !== 'dir') ? -1 : (($b['type'] === 'dir' && $a['type'] !== 'dir') ? 1 : strcasecmp($a['basename'], $b['basename'])));
|
||||
|
||||
Log::debug("StorageRepository: listContents repo #{$repo->id} tipo={$repo->tipo} path='{$normalizedPath}' results=" . count($result));
|
||||
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
Log::error("StorageRepository: listContents failed for repo #{$repo->id} path '{$path}': " . $e->getMessage());
|
||||
@@ -160,12 +177,16 @@ class StorageRepositoryService
|
||||
$client = new \Google_Client();
|
||||
$client->setClientId($config['client_id']);
|
||||
$client->setClientSecret($config['client_secret']);
|
||||
$client->refreshToken($config['refresh_token']);
|
||||
$client->addScope(\Google_Service_Drive::DRIVE);
|
||||
|
||||
// Refresh token per ottenere un access token valido
|
||||
$token = $client->refreshToken($config['refresh_token']);
|
||||
$client->setAccessToken($token);
|
||||
|
||||
$service = new \Google_Service_Drive($client);
|
||||
|
||||
$adapter = new GoogleDriveAdapter($service, $config['root_folder_id'] ?? 'root');
|
||||
$rootFolderId = $config['root_folder_id'] ?? 'root';
|
||||
$adapter = new GoogleDriveAdapter($service, $rootFolderId);
|
||||
|
||||
return new Filesystem($adapter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user