mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 18:44:30 +00:00
Make WebDAV mapping lookup robust by webdav_path
This commit is contained in:
@@ -87,7 +87,18 @@ function bratonien_tools_webdav_materialize_source_info($image_id)
|
|||||||
$mapping = json_decode((string)file_get_contents($mapping_file), true);
|
$mapping = json_decode((string)file_get_contents($mapping_file), true);
|
||||||
if (is_array($mapping) && isset($mapping['files']) && is_array($mapping['files']))
|
if (is_array($mapping) && isset($mapping['files']) && is_array($mapping['files']))
|
||||||
{
|
{
|
||||||
$entry = $mapping['files'][$resolved] ?? $mapping['files'][$normalized] ?? null;
|
$files = $mapping['files'];
|
||||||
|
$entry = $files[$resolved] ?? $files[$normalized] ?? null;
|
||||||
|
if (!is_array($entry))
|
||||||
|
{
|
||||||
|
foreach ($files as $candidate)
|
||||||
|
{
|
||||||
|
if (!is_array($candidate) || (string)($candidate['kind'] ?? '') !== 'file') continue;
|
||||||
|
if (trim((string)($candidate['webdav_path'] ?? ''), '/') !== $webdav_path) continue;
|
||||||
|
$entry = $candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (is_array($entry) && (string)($entry['kind'] ?? '') === 'file')
|
if (is_array($entry) && (string)($entry['kind'] ?? '') === 'file')
|
||||||
{
|
{
|
||||||
$mapped_path = trim((string)($entry['webdav_path'] ?? ''), '/');
|
$mapped_path = trim((string)($entry['webdav_path'] ?? ''), '/');
|
||||||
|
|||||||
Reference in New Issue
Block a user