Skip to content

Commit

Permalink
Set SEAF_ERR_BAD_ARGS when args is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed May 6, 2024
1 parent 3699031 commit 0c845a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions python/seaserv/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,14 @@ def put_file(self, repo_id, tmp_file_path, parent_dir, filename,
filename, username, head_id)

'''
If you want to delete multiple files in a batch, @filename should be in
the following format: '["filename1", "filename2", "filename3"]'
If you want to delete multiple files in a batch, @filename should be json array
'''
def del_file(self, repo_id, parent_dir, filename, username):
return seafserv_threaded_rpc.del_file(repo_id, parent_dir, filename, username)

'''
If you want to move or copy multiple files in a batch, @src_filename and @dst_filename
should be in the following format: '["filename1", "filename2", "filename3"]',make sure the number of files
should be json array, make sure the number of files
in @src_filename and @dst_filename parameters match
'''
def copy_file(self, src_repo, src_dir, src_filename, dst_repo,
Expand Down
16 changes: 8 additions & 8 deletions server/repo-op.c
Original file line number Diff line number Diff line change
Expand Up @@ -2809,14 +2809,14 @@ seaf_repo_manager_copy_multiple_files (SeafRepoManager *mgr,
dst_names = json_to_file_list (dst_filenames);
if (!src_names || !dst_names) {
ret = -1;
seaf_warning ("[copy files] Bad args: Load filenames to json failed.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Load filenames to json failed");
goto out;
}
file_num = g_list_length (src_names);
int dst_file_num = g_list_length (dst_names);
if (dst_file_num != file_num) {
ret = -1;
seaf_warning ("[copy files] Bad args.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "The number of files in the parameters does not match");
goto out;
}

Expand Down Expand Up @@ -2846,7 +2846,7 @@ seaf_repo_manager_copy_multiple_files (SeafRepoManager *mgr,
name = ptr->data;
if (strcmp(name, "") == 0) {
ret = -1;
seaf_warning ("[copy files] Bad args: Empty src_filenames.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Empty src_filenames");
goto out;
}
src_dents[i] = g_hash_table_lookup(dirent_hash, name);
Expand All @@ -2865,7 +2865,7 @@ seaf_repo_manager_copy_multiple_files (SeafRepoManager *mgr,
name = ptr->data;
if (strcmp(name, "") == 0) {
ret = -1;
seaf_warning ("[copy files] Bad args: Empty dst_filenames.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Empty dst_filenames");
goto out;
}
/* duplicate src dirents with new names */
Expand Down Expand Up @@ -3336,15 +3336,15 @@ seaf_repo_manager_move_multiple_files (SeafRepoManager *mgr,
dst_names = json_to_file_list (dst_filenames);
if (!src_names || !dst_names) {
ret = -1;
seaf_warning ("[move files] Bad args: Load filenames to json failed.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Load filenames to json failed");
goto out;
}

file_num = g_list_length (src_names);
int dst_file_num = g_list_length (dst_names);
if (dst_file_num != file_num) {
ret = -1;
seaf_warning ("[move files] Bad args.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "The number of files in the parameters does not match");
goto out;
}

Expand Down Expand Up @@ -3373,7 +3373,7 @@ seaf_repo_manager_move_multiple_files (SeafRepoManager *mgr,
name = ptr->data;
if (strcmp(name, "") == 0) {
ret = -1;
seaf_warning ("[move files] Bad args: Empty src_filenames.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Empty src_filenames");
goto out;
}
src_dents[i] = g_hash_table_lookup(dirent_hash, name);
Expand All @@ -3392,7 +3392,7 @@ seaf_repo_manager_move_multiple_files (SeafRepoManager *mgr,
name = ptr->data;
if (strcmp(name, "") == 0) {
ret = -1;
seaf_warning ("[move files] Bad args: Empty dst_filenames.\n");
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Empty dst_filenames");
goto out;
}
/* duplicate src dirents with new names */
Expand Down

0 comments on commit 0c845a0

Please sign in to comment.