mirror of
https://github.com/unraid/webgui.git
synced 2026-01-11 03:59:57 -06:00
Enable parent-to-subdirectory check for rsync-rename moves
Prevents moving a directory into its own subdirectory, which would cause rsync --backup-dir to create nested structures and fail to delete source. Example prevented: /mnt/disk1/parent → /mnt/disk1/parent/subfolder The check uses trailing slashes to ensure exact directory boundary matching and prevent false positives (e.g., /parent vs /parent2).
This commit is contained in:
@@ -334,13 +334,13 @@ while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
// // target must not be a subdirectory of source parent (backup-dir should be outside source tree)
|
||||
// $source_parent_dir = dirname($valid_source_path);
|
||||
// if (strpos(rtrim($target,'/'), rtrim($source_parent_dir,'/') . '/') === 0) {
|
||||
// $reply['error'] = 'Cannot move directory into its own subdirectory';
|
||||
// $use_rsync_rename = false;
|
||||
// break 2; // break out of both foreach and if
|
||||
// }
|
||||
// target must not be a subdirectory of any source (backup-dir should be outside source tree)
|
||||
$parent_dir = dirname($valid_source_path);
|
||||
if (strpos(rtrim($target,'/') . '/', rtrim($parent_dir,'/') . '/') === 0) {
|
||||
$reply['error'] = 'Cannot move directory into its own subdirectory';
|
||||
$use_rsync_rename = false;
|
||||
break 2; // break out of both foreach and if
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user