Skip to content

Commit

Permalink
Improve args
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Sep 12, 2024
1 parent 482c075 commit 8f855b3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions server/repo-op.c
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ del_file_recursive(SeafRepo *repo,

out:
if (p_deleted_num)
*p_deleted_num += deleted_num;
*p_deleted_num = deleted_num;

g_free (to_path_dup);
g_free (id);
Expand Down Expand Up @@ -1850,36 +1850,34 @@ do_batch_del_files (ChangeSet *changeset,
const char *file_list,
int *mode, int *deleted_num, char **desc_file)
{
GList *filenames = NULL, *ptr;
GList *filepaths = NULL, *ptr;
char *name;

filenames = json_to_file_list (file_list);
filepaths = json_to_file_list (file_list);

for (ptr = filenames; ptr; ptr = ptr->next) {
for (ptr = filepaths; ptr; ptr = ptr->next) {
name = ptr->data;
if (!name || g_strcmp0 (name, "") == 0) {
continue;
}
char *canon_path = get_canonical_path (name);
char *parent_dir = g_path_get_dirname (canon_path);
char *base_name= g_path_get_basename (canon_path);
char *del_path = canon_path;
if (canon_path[0] == '/') {
del_path = canon_path + 1;
}

remove_from_changeset (changeset, del_path, FALSE, parent_dir, mode);
remove_from_changeset (changeset, del_path, FALSE, NULL, mode);

(*deleted_num)++;
if (desc_file && *desc_file == NULL)
*desc_file = g_strdup (base_name);

g_free (canon_path);
g_free (parent_dir);
g_free (base_name);
}

string_list_free (filenames);
string_list_free (filepaths);
}

int
Expand Down Expand Up @@ -1929,6 +1927,7 @@ seaf_repo_manager_batch_del_files (SeafRepoManager *mgr,

root_id = commit_tree_from_changeset (changeset);
if (!root_id) {
seaf_warning ("Failed to commit changeset for repo %s.\n", repo_id);
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
"Failed to batch del files");
ret = -1;
Expand Down

0 comments on commit 8f855b3

Please sign in to comment.