-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add batch del files RPC #694
Conversation
server/repo-op.c
Outdated
char *canon_path = get_canonical_path (parent_dir); | ||
char *tmp_file_list = g_strdup_printf ("[\"%s\"]", base_name); | ||
|
||
char *new_root_id = do_del_file (repo, next_root_id, canon_path, tmp_file_list, mode, deleted_num, desc_file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在这样实现有一个潜在问题的吧,如果这个 RPC 被调用很多次,或者一次删除很多个文件,就会产生很多没用的 dir 对象,都保存下来了,会导致存储里面没用的 fs 对象数量增多。这里应该要花心思做一下缓存优化,可以把客户端的 change set 代码借用过来,如果多个被删除的文件实在同一个目录下面的,不用把这个目录保存很多次。如果只是现在这样的实现,就等同于让 seahub 直接多次调用原有的 del_file RPC。
} | ||
|
||
seaf_repo_manager_merge_virtual_repo (mgr, repo_id, NULL); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该参考 del_file 的实现吧,还需要处理一下 locked files 和 folder permission。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是因为开源版没有文件锁定和目录权限。
fileserver/fsmgr/fsmgr.go
Outdated
} | ||
} | ||
|
||
return nil, fmt.Errorf("failed to get dirent %s", rpath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该返回 ErrPathNotExist。
server/repo-op.c
Outdated
GList *filenames = NULL, *ptr; | ||
char *name; | ||
|
||
filenames = json_to_file_list (file_list); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filenames -> filepaths
server/repo-op.c
Outdated
del_path = canon_path + 1; | ||
} | ||
|
||
remove_from_changeset (changeset, del_path, FALSE, parent_dir, mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent_dir 这个参数应该可以设置为 NULL 的吧,因为只有在递归删除空的父目录的时候才需要用到。
server/repo-op.c
Outdated
@@ -1735,7 +1736,7 @@ del_file_recursive(SeafRepo *repo, | |||
|
|||
out: | |||
if (p_deleted_num) | |||
*p_deleted_num = deleted_num; | |||
*p_deleted_num += deleted_num; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不用改了吧。
} | ||
|
||
root_id = commit_tree_from_changeset (changeset); | ||
if (!root_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里打印一下日志吧。
No description provided.