Skip to content

Commit

Permalink
Don't support move directory to its subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Feb 2, 2024
1 parent 1e4790b commit 66766b8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/repo-op.c
Original file line number Diff line number Diff line change
Expand Up @@ -3491,6 +3491,26 @@ seaf_repo_manager_move_multiple_files (SeafRepoManager *mgr,
}

gboolean is_virtual_origin = is_virtual_repo_and_origin (src_repo, dst_repo);
// Check if moving files to subdir.
if (src_repo == dst_repo && !is_virtual_origin) {
char *src_dirent_path = NULL;
int len;
for (ptr = src_names; ptr; ptr = ptr->next) {
name = ptr->data;
src_dirent_path = g_build_path ("/", src_path, name, "/", NULL);
len = strlen(src_dirent_path);
if (strncmp (dst_path, src_dirent_path, len) == 0) {
g_free (src_dirent_path);
ret = -1;
seaf_warning ("[move files] Can not move directory to its subdirectory");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
"Can not move directory to its subdirectory");
goto out;
}
g_free (src_dirent_path);
}
}

if (src_repo == dst_repo || is_virtual_origin) {
/* get src dirents */

Expand Down

0 comments on commit 66766b8

Please sign in to comment.