From 50feeccd45d3e430c78094250ac3250f849d9fce Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Tue, 18 Aug 2026 09:00:16 +0200 Subject: [PATCH] Allow storage root mappings and improve connector validation --- include/nc_connector_manage.inc.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/nc_connector_manage.inc.php b/include/nc_connector_manage.inc.php index f6175fe..0e398c0 100644 --- a/include/nc_connector_manage.inc.php +++ b/include/nc_connector_manage.inc.php @@ -29,15 +29,24 @@ function bratonien_tools_nc_connector_encrypt_credentials($db_password, $piwigo_ function bratonien_tools_nc_connector_parse_storages($raw) { - $storages=array();$lines=preg_split('/\r\n|\r|\n/',trim((string)$raw)); + $storages=array(); + $lines=preg_split('/\r\n|\r|\n/',trim((string)$raw)); foreach($lines as $line) { - $line=trim($line);if($line==='')continue;$parts=array_map('trim',explode('|',$line)); - if(count($parts)!==3||$parts[0]===''||$parts[1]===''||$parts[2]==='')throw new RuntimeException('Storage-Zeilen muessen das Format storage_id | source_prefix | local_mount verwenden.'); - if($parts[2][0]!=='/')throw new RuntimeException('Der lokale Storage-Mount muss ein absoluter Pfad sein.'); - $storages[]=array('storage_id'=>$parts[0],'source_prefix'=>$parts[1],'local_mount'=>rtrim($parts[2],'/')); + if(trim($line)==='') continue; + $parts=array_map('trim',explode('|',$line,3)); + if(count($parts)!==3 || $parts[0]==='' || $parts[2]==='') + { + throw new RuntimeException('Eine Speicherzuordnung ist unvollständig. Benötigt werden Storage-ID und lokaler Speicherpfad.'); + } + if($parts[2][0]!=='/') throw new RuntimeException('Der lokale Speicherpfad muss ein absoluter Pfad sein.'); + $storages[]=array( + 'storage_id'=>$parts[0], + 'source_prefix'=>trim($parts[1],'/'), + 'local_mount'=>rtrim($parts[2],'/'), + ); } - if(!$storages)throw new RuntimeException('Mindestens ein Storage muss konfiguriert werden.'); + if(!$storages) throw new RuntimeException('Mindestens ein Speicherort muss zugeordnet werden.'); return $storages; }