Fixup deletePath. Handle links, and report failures. Fix escaping the filename and put it in quotes in case it has spaces. Fixes #4446

pull/4430/merge
Isaac Connor 2025-10-03 16:10:32 -04:00
parent 8f475faf12
commit fdfe87be38
1 changed files with 9 additions and 3 deletions

View File

@ -362,10 +362,16 @@ function getEventDefaultVideoPath($event) {
function deletePath( $path ) {
ZM\Debug('Deleting '.$path);
if (is_dir($path)) {
system(escapeshellcmd('rm -rf '.$path));
if (is_link($path)) {
if (!unlink($path)) ZM\Debug("Failed to unlink $path");
} else if (is_dir($path)) {
if (false === ($output = system('rm -rf "'.escapeshellcmd($path).'"'))) {
ZM\Warning('Failed doing rm -rf "'.escapeshellcmd($path).'"');
}
} else if (file_exists($path)) {
unlink($path);
if (!unlink($path)) ZM\Debug("Failed to delete $path");
} else {
ZM\Warning("Path $path does not exist in deletePath()");
}
}