You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (strpos(rtrim($target,'/') . '/', rtrim($source_dirname,'/') . '/') === 0) {
546
-
$reply['error'] = _('Cannot move directory into its own subdirectory');
547
-
$use_rsync_rename = false;
548
-
break2; // break out of both: foreach and case
543
+
// target must not be a subdirectory of any source directory (backup-dir should be outside source tree)
544
+
// This check is only relevant when moving directories, not files
545
+
if (is_dir($valid_source_path)) {
546
+
if (strpos(rtrim($target,'/') . '/', rtrim($valid_source_path,'/') . '/') === 0) {
547
+
$reply['error'] = _('Cannot move directory into its own subdirectory');
548
+
$use_rsync_rename = false;
549
+
break2; // break out of both: foreach and case
550
+
}
549
551
}
550
552
551
553
}
@@ -557,9 +559,34 @@ while (true) {
557
559
// - existing files are overwritten in --backup-dir (like not using --ignore-existing)
558
560
// - missing directories are created in --backup-dir (like using --mkpath)
559
561
// - rsync prefixes the moved files with "deleting " in the output, which we strip with sed, to not confuse the user
562
+
// - rsync --backup deletes empty directories instead of moving them to --backup-dir (https://github.com/RsyncProject/rsync/issues/842), so we copy empty directories first
0 commit comments