Use relative symlinks for monitor event directories

This way the link continues to work from backups and after the user moves ZM data to a new directory.
This commit is contained in:
Matt N 2020-11-01 14:55:08 -08:00 committed by GitHub
parent 3d795be864
commit 6e3eb922e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -121,7 +121,8 @@ if ( $action == 'save' ) {
}
$saferNewName = basename($_REQUEST['newMonitor']['Name']);
$link_path = $NewStorage->Path().'/'.$saferNewName;
if ( !symlink($NewStorage->Path().'/'.$mid, $link_path) ) {
// Use a relative path for the target so the link continues to work from backups or directory changes.
if ( !symlink($mid, $link_path) ) {
if ( ! ( file_exists($link_path) and is_link($link_path) ) ) {
ZM\Warning('Unable to symlink ' . $NewStorage->Path().'/'.$mid . ' to ' . $NewStorage->Path().'/'.$saferNewName);
}