mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 10:34:30 +00:00
Compare commits
9 Commits
238c06be33
...
f958eca176
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f958eca176 | ||
|
|
93af719143 | ||
|
|
11183f2a41 | ||
|
|
26bb454ba4 | ||
|
|
a195421fed | ||
|
|
ec55220124 | ||
|
|
f5d3b97339 | ||
|
|
a5b4a2329e | ||
|
|
97340a517b |
@@ -43,16 +43,49 @@ function bratonien_tools_nc_connector_systemctl_value(array $args)
|
||||
|
||||
function bratonien_tools_nc_connector_run_now()
|
||||
{
|
||||
$service = 'bratonien-nc-connector.service';
|
||||
$result = bratonien_tools_nc_connector_systemctl_run(array('start','--no-block',$service));
|
||||
if ($result['exit'] !== 0)
|
||||
if (!function_exists('proc_open'))
|
||||
{
|
||||
$detail = $result['stderr'] !== '' ? $result['stderr'] : $result['stdout'];
|
||||
if ($detail === '') $detail = 'systemctl Exit-Code '.$result['exit'];
|
||||
throw new RuntimeException('WebDAV-Abgleich konnte nicht gestartet werden: '.$detail);
|
||||
throw new RuntimeException('WebDAV-Abgleich konnte nicht gestartet werden: proc_open ist in PHP nicht verfügbar.');
|
||||
}
|
||||
|
||||
return array('message'=>'WebDAV-Abgleich wurde gestartet.');
|
||||
$runtime_dir = realpath(dirname(__DIR__).'/runtime');
|
||||
if ($runtime_dir === false || !is_dir($runtime_dir))
|
||||
{
|
||||
throw new RuntimeException('WebDAV-Abgleich konnte nicht gestartet werden: Runtime-Verzeichnis wurde nicht gefunden.');
|
||||
}
|
||||
|
||||
$script = $runtime_dir.'/run-all.sh';
|
||||
if (!is_file($script) || !is_readable($script))
|
||||
{
|
||||
throw new RuntimeException('WebDAV-Abgleich konnte nicht gestartet werden: runtime/run-all.sh ist nicht lesbar.');
|
||||
}
|
||||
|
||||
$spec = array(
|
||||
0=>array('file','/dev/null','r'),
|
||||
1=>array('pipe','w'),
|
||||
2=>array('pipe','w'),
|
||||
);
|
||||
$environment = array_merge($_ENV, array('LC_ALL'=>'C','LANG'=>'C'));
|
||||
$process = @proc_open(array('/usr/bin/env','bash',$script), $spec, $pipes, $runtime_dir, $environment);
|
||||
if (!is_resource($process))
|
||||
{
|
||||
throw new RuntimeException('WebDAV-Abgleich konnte nicht gestartet werden: Connector-Prozess konnte nicht geöffnet werden.');
|
||||
}
|
||||
|
||||
$stdout = trim((string)stream_get_contents($pipes[1]));
|
||||
$stderr = trim((string)stream_get_contents($pipes[2]));
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
$exit = (int)proc_close($process);
|
||||
|
||||
if ($exit !== 0)
|
||||
{
|
||||
$detail = $stderr !== '' ? $stderr : $stdout;
|
||||
if ($detail === '') $detail = 'Exit-Code '.$exit;
|
||||
throw new RuntimeException('WebDAV-Abgleich fehlgeschlagen: '.$detail);
|
||||
}
|
||||
|
||||
return array('message'=>'WebDAV-Abgleich wurde ausgeführt.');
|
||||
}
|
||||
|
||||
function bratonien_tools_nc_connector_parse_systemd_time($value)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Bratonien Tools
|
||||
Version: 0.9.6.8.11
|
||||
Version: 0.9.6.8.15
|
||||
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
||||
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
||||
Author: Bratonien
|
||||
@@ -124,4 +124,4 @@ function bratonien_tools_admin_menu($menu)
|
||||
);
|
||||
return $menu;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
@@ -269,7 +269,20 @@ def main() -> int:
|
||||
total_files += files
|
||||
total_folders += folders
|
||||
total_skipped += skipped
|
||||
manifest.append(f"webdav:{fileid}\tfolder\t{display}\t{source_dir / local_name}")
|
||||
|
||||
if remote_root == "":
|
||||
for child in sorted(local_root.iterdir(), key=lambda item: (item.name.casefold(), item.name)):
|
||||
child_data = mapping.get(str(child))
|
||||
if not child_data:
|
||||
continue
|
||||
child_fileid = int(child_data.get("fileid", 0))
|
||||
child_display = str(child_data.get("display_name", "")).strip() or child.name
|
||||
child_type = "folder" if child.is_dir() else "file"
|
||||
manifest.append(
|
||||
f"webdav:{child_fileid}\t{child_type}\t{child_display}\t{source_dir / local_name / child.name}"
|
||||
)
|
||||
else:
|
||||
manifest.append(f"webdav:{fileid}\tfolder\t{display}\t{source_dir / local_name}")
|
||||
|
||||
if previous.exists():
|
||||
shutil.rmtree(previous)
|
||||
|
||||
@@ -180,7 +180,7 @@ try
|
||||
{
|
||||
$path = trim((string)($root['webdav_path'] ?? ''), '/');
|
||||
$display = trim((string)($root['display_name'] ?? ''));
|
||||
if ($path === '' || $display === '' || preg_match('/[\t\r\n]/', $path.$display)) fail_webdav_reconcile('Eine gespeicherte WebDAV-Wurzel ist ungueltig.');
|
||||
if ($display === '' || preg_match('/[\t\r\n]/', $path.$display)) fail_webdav_reconcile('Eine gespeicherte WebDAV-Wurzel ist ungueltig.');
|
||||
$rootLines[] = $path."\t".$display;
|
||||
}
|
||||
file_put_contents($rootsPath, implode("\n", $rootLines)."\n", LOCK_EX);
|
||||
|
||||
@@ -72,8 +72,10 @@ failure() {
|
||||
trap 'failure $? "$BASH_COMMAND" "$LINENO"' ERR
|
||||
|
||||
ROOT_ARGS=()
|
||||
while IFS=$'\t' read -r path display_name; do
|
||||
[[ -z "$path" || "$path" == \#* ]] && continue
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" || "$line" == \#* ]] && continue
|
||||
[[ "$line" == *$'\t'* ]] || continue
|
||||
path="${line%%$'\t'*}"
|
||||
ROOT_ARGS+=(--root "$path")
|
||||
done < "$WEBDAV_ROOTS_FILE"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user