diff --git a/common/rpc-service.c b/common/rpc-service.c index fdc57ba..6c6baba 100644 --- a/common/rpc-service.c +++ b/common/rpc-service.c @@ -3274,67 +3274,67 @@ out: return ret; } -char * -seafile_post_file_blocks (const char *repo_id, - const char *parent_dir, - const char *file_name, - const char *blockids_json, - const char *paths_json, - const char *user, - gint64 file_size, - int replace_existed, - GError **error) -{ - char *norm_parent_dir = NULL, *norm_file_name = NULL, *rpath = NULL; - char *new_id = NULL; +/* char * */ +/* seafile_post_file_blocks (const char *repo_id, */ +/* const char *parent_dir, */ +/* const char *file_name, */ +/* const char *blockids_json, */ +/* const char *paths_json, */ +/* const char *user, */ +/* gint64 file_size, */ +/* int replace_existed, */ +/* GError **error) */ +/* { */ +/* char *norm_parent_dir = NULL, *norm_file_name = NULL, *rpath = NULL; */ +/* char *new_id = NULL; */ - if (!repo_id || !parent_dir || !file_name - || !blockids_json || ! paths_json || !user || file_size < 0) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Argument should not be null"); - return NULL; - } +/* if (!repo_id || !parent_dir || !file_name */ +/* || !blockids_json || ! paths_json || !user || file_size < 0) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Argument should not be null"); */ +/* return NULL; */ +/* } */ - if (!is_uuid_valid (repo_id)) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id"); - return NULL; - } +/* if (!is_uuid_valid (repo_id)) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id"); */ +/* return NULL; */ +/* } */ - norm_parent_dir = normalize_utf8_path (parent_dir); - if (!norm_parent_dir) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Path is in valid UTF8 encoding"); - goto out; - } +/* norm_parent_dir = normalize_utf8_path (parent_dir); */ +/* if (!norm_parent_dir) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Path is in valid UTF8 encoding"); */ +/* goto out; */ +/* } */ - norm_file_name = normalize_utf8_path (file_name); - if (!norm_file_name) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Path is in valid UTF8 encoding"); - goto out; - } +/* norm_file_name = normalize_utf8_path (file_name); */ +/* if (!norm_file_name) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Path is in valid UTF8 encoding"); */ +/* goto out; */ +/* } */ - rpath = format_dir_path (norm_parent_dir); +/* rpath = format_dir_path (norm_parent_dir); */ - seaf_repo_manager_post_file_blocks (seaf->repo_mgr, - repo_id, - rpath, - norm_file_name, - blockids_json, - paths_json, - user, - file_size, - replace_existed, - &new_id, - error); +/* seaf_repo_manager_post_file_blocks (seaf->repo_mgr, */ +/* repo_id, */ +/* rpath, */ +/* norm_file_name, */ +/* blockids_json, */ +/* paths_json, */ +/* user, */ +/* file_size, */ +/* replace_existed, */ +/* &new_id, */ +/* error); */ -out: - g_free (norm_parent_dir); - g_free (norm_file_name); - g_free (rpath); +/* out: */ +/* g_free (norm_parent_dir); */ +/* g_free (norm_file_name); */ +/* g_free (rpath); */ - return new_id; -} +/* return new_id; */ +/* } */ char * seafile_post_multi_files (const char *repo_id, @@ -3434,56 +3434,56 @@ out: return new_file_id; } -char * -seafile_put_file_blocks (const char *repo_id, const char *parent_dir, - const char *file_name, const char *blockids_json, - const char *paths_json, const char *user, - const char *head_id, gint64 file_size, GError **error) -{ - char *norm_parent_dir = NULL, *norm_file_name = NULL, *rpath = NULL; - char *new_file_id = NULL; +/* char * */ +/* seafile_put_file_blocks (const char *repo_id, const char *parent_dir, */ +/* const char *file_name, const char *blockids_json, */ +/* const char *paths_json, const char *user, */ +/* const char *head_id, gint64 file_size, GError **error) */ +/* { */ +/* char *norm_parent_dir = NULL, *norm_file_name = NULL, *rpath = NULL; */ +/* char *new_file_id = NULL; */ - if (!repo_id || !parent_dir || !file_name - || !blockids_json || ! paths_json || !user) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Argument should not be null"); - return NULL; - } +/* if (!repo_id || !parent_dir || !file_name */ +/* || !blockids_json || ! paths_json || !user) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Argument should not be null"); */ +/* return NULL; */ +/* } */ - if (!is_uuid_valid (repo_id)) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id"); - return NULL; - } +/* if (!is_uuid_valid (repo_id)) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id"); */ +/* return NULL; */ +/* } */ - norm_parent_dir = normalize_utf8_path (parent_dir); - if (!norm_parent_dir) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Path is in valid UTF8 encoding"); - goto out; - } +/* norm_parent_dir = normalize_utf8_path (parent_dir); */ +/* if (!norm_parent_dir) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Path is in valid UTF8 encoding"); */ +/* goto out; */ +/* } */ - norm_file_name = normalize_utf8_path (file_name); - if (!norm_file_name) { - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Path is in valid UTF8 encoding"); - goto out; - } +/* norm_file_name = normalize_utf8_path (file_name); */ +/* if (!norm_file_name) { */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Path is in valid UTF8 encoding"); */ +/* goto out; */ +/* } */ - rpath = format_dir_path (norm_parent_dir); +/* rpath = format_dir_path (norm_parent_dir); */ - seaf_repo_manager_put_file_blocks (seaf->repo_mgr, repo_id, - rpath, norm_file_name, - blockids_json, paths_json, - user, head_id, file_size, - &new_file_id, error); +/* seaf_repo_manager_put_file_blocks (seaf->repo_mgr, repo_id, */ +/* rpath, norm_file_name, */ +/* blockids_json, paths_json, */ +/* user, head_id, file_size, */ +/* &new_file_id, error); */ -out: - g_free (norm_parent_dir); - g_free (norm_file_name); - g_free (rpath); +/* out: */ +/* g_free (norm_parent_dir); */ +/* g_free (norm_file_name); */ +/* g_free (rpath); */ - return new_file_id; -} +/* return new_file_id; */ +/* } */ int seafile_post_dir (const char *repo_id, const char *parent_dir, diff --git a/include/seafile-rpc.h b/include/seafile-rpc.h index ca863ae..b83d4db 100644 --- a/include/seafile-rpc.h +++ b/include/seafile-rpc.h @@ -683,16 +683,16 @@ seafile_post_multi_files (const char *repo_id, * @blocks_json: json array of block ids * @paths_json: json array of temp file paths */ -char * -seafile_post_file_blocks (const char *repo_id, - const char *parent_dir, - const char *file_name, - const char *blockids_json, - const char *paths_json, - const char *user, - gint64 file_size, - int replace_existed, - GError **error); +/* char * */ +/* seafile_post_file_blocks (const char *repo_id, */ +/* const char *parent_dir, */ +/* const char *file_name, */ +/* const char *blockids_json, */ +/* const char *paths_json, */ +/* const char *user, */ +/* gint64 file_size, */ +/* int replace_existed, */ +/* GError **error); */ int @@ -719,11 +719,11 @@ seafile_put_file (const char *repo_id, const char *temp_file_path, * @blocks_json: json array of block ids * @paths_json: json array of temp file paths */ -char * -seafile_put_file_blocks (const char *repo_id, const char *parent_dir, - const char *file_name, const char *blockids_json, - const char *paths_json, const char *user, - const char *head_id, gint64 file_size, GError **error); +/* char * */ +/* seafile_put_file_blocks (const char *repo_id, const char *parent_dir, */ +/* const char *file_name, const char *blockids_json, */ +/* const char *paths_json, const char *user, */ +/* const char *head_id, gint64 file_size, GError **error); */ int diff --git a/server/repo-mgr.h b/server/repo-mgr.h index b439cba..3735ab7 100644 --- a/server/repo-mgr.h +++ b/server/repo-mgr.h @@ -318,18 +318,19 @@ seaf_repo_manager_post_multi_files (SeafRepoManager *mgr, char **new_ids, GError **error); -int -seaf_repo_manager_post_file_blocks (SeafRepoManager *mgr, - const char *repo_id, - const char *parent_dir, - const char *file_name, - const char *blockids_json, - const char *paths_json, - const char *user, - gint64 file_size, - int replace_existed, - char **new_id, - GError **error); +/* int */ +/* seaf_repo_manager_post_file_blocks (SeafRepoManager *mgr, */ +/* const char *repo_id, */ +/* const char *parent_dir, */ +/* const char *file_name, */ +/* const char *blockids_json, */ +/* const char *paths_json, */ +/* const char *user, */ +/* gint64 file_size, */ +/* int replace_existed, */ +/* char **new_id, */ +/* GError **error); */ + int seaf_repo_manager_post_blocks (SeafRepoManager *mgr, const char *repo_id, @@ -392,18 +393,18 @@ seaf_repo_manager_put_file (SeafRepoManager *mgr, char **new_file_id, GError **error); -int -seaf_repo_manager_put_file_blocks (SeafRepoManager *mgr, - const char *repo_id, - const char *parent_dir, - const char *file_name, - const char *blockids_json, - const char *paths_json, - const char *user, - const char *head_id, - gint64 file_size, - char **new_file_id, - GError **error); +/* int */ +/* seaf_repo_manager_put_file_blocks (SeafRepoManager *mgr, */ +/* const char *repo_id, */ +/* const char *parent_dir, */ +/* const char *file_name, */ +/* const char *blockids_json, */ +/* const char *paths_json, */ +/* const char *user, */ +/* const char *head_id, */ +/* gint64 file_size, */ +/* char **new_file_id, */ +/* GError **error); */ int seaf_repo_manager_del_file (SeafRepoManager *mgr, diff --git a/server/repo-op.c b/server/repo-op.c index 06f77d6..3cd8ab3 100644 --- a/server/repo-op.c +++ b/server/repo-op.c @@ -1127,123 +1127,123 @@ out: return ret; } -int -seaf_repo_manager_post_file_blocks (SeafRepoManager *mgr, - const char *repo_id, - const char *parent_dir, - const char *file_name, - const char *blockids_json, - const char *paths_json, - const char *user, - gint64 file_size, - int replace_existed, - char **new_id, - GError **error) -{ - SeafRepo *repo = NULL; - SeafCommit *head_commit = NULL; - char *canon_path = NULL; - unsigned char sha1[20]; - char buf[SEAF_PATH_MAX]; - char *root_id = NULL; - SeafDirent *new_dent = NULL; - GList *blockids = NULL, *paths = NULL, *ptr; - char hex[41]; - int ret = 0; +/* int */ +/* seaf_repo_manager_post_file_blocks (SeafRepoManager *mgr, */ +/* const char *repo_id, */ +/* const char *parent_dir, */ +/* const char *file_name, */ +/* const char *blockids_json, */ +/* const char *paths_json, */ +/* const char *user, */ +/* gint64 file_size, */ +/* int replace_existed, */ +/* char **new_id, */ +/* GError **error) */ +/* { */ +/* SeafRepo *repo = NULL; */ +/* SeafCommit *head_commit = NULL; */ +/* char *canon_path = NULL; */ +/* unsigned char sha1[20]; */ +/* char buf[SEAF_PATH_MAX]; */ +/* char *root_id = NULL; */ +/* SeafDirent *new_dent = NULL; */ +/* GList *blockids = NULL, *paths = NULL, *ptr; */ +/* char hex[41]; */ +/* int ret = 0; */ - blockids = json_to_file_list (blockids_json); - paths = json_to_file_list (paths_json); - if (g_list_length(blockids) != g_list_length(paths)) { - seaf_debug ("[post-blks] Invalid blockids or paths.\n"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid files"); - ret = -1; - goto out; - } +/* blockids = json_to_file_list (blockids_json); */ +/* paths = json_to_file_list (paths_json); */ +/* if (g_list_length(blockids) != g_list_length(paths)) { */ +/* seaf_debug ("[post-blks] Invalid blockids or paths.\n"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid files"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - for (ptr = paths; ptr; ptr = ptr->next) { - char *temp_file_path = ptr->data; - if (g_access (temp_file_path, R_OK) != 0) { - seaf_warning ("[post-blks] File block %s doesn't exist or not readable.\n", - temp_file_path); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Invalid input file"); - ret = -1; - goto out; - } - } +/* for (ptr = paths; ptr; ptr = ptr->next) { */ +/* char *temp_file_path = ptr->data; */ +/* if (g_access (temp_file_path, R_OK) != 0) { */ +/* seaf_warning ("[post-blks] File block %s doesn't exist or not readable.\n", */ +/* temp_file_path); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Invalid input file"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ +/* } */ - GET_REPO_OR_FAIL(repo, repo_id); - GET_COMMIT_OR_FAIL(head_commit, repo->id, repo->version, repo->head->commit_id); +/* GET_REPO_OR_FAIL(repo, repo_id); */ +/* GET_COMMIT_OR_FAIL(head_commit, repo->id, repo->version, repo->head->commit_id); */ - if (!canon_path) - canon_path = get_canonical_path (parent_dir); +/* if (!canon_path) */ +/* canon_path = get_canonical_path (parent_dir); */ - if (should_ignore_file (file_name, NULL)) { - seaf_debug ("[post-blks] Invalid filename %s.\n", file_name); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Invalid filename"); - ret = -1; - goto out; - } +/* if (should_ignore_file (file_name, NULL)) { */ +/* seaf_debug ("[post-blks] Invalid filename %s.\n", file_name); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Invalid filename"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - if (strstr (parent_dir, "//") != NULL) { - seaf_debug ("[post-blks] parent_dir cantains // sequence.\n"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Invalid parent dir"); - ret = -1; - goto out; - } +/* if (strstr (parent_dir, "//") != NULL) { */ +/* seaf_debug ("[post-blks] parent_dir cantains // sequence.\n"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Invalid parent dir"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - /* Write blocks. */ - if (seaf_fs_manager_index_file_blocks (seaf->fs_mgr, - repo->store_id, repo->version, - paths, - blockids, sha1, file_size) < 0) { - seaf_warning ("Failed to index file blocks"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, - "Failed to index blocks"); - ret = -1; - goto out; - } +/* /\* Write blocks. *\/ */ +/* if (seaf_fs_manager_index_file_blocks (seaf->fs_mgr, */ +/* repo->store_id, repo->version, */ +/* paths, */ +/* blockids, sha1, file_size) < 0) { */ +/* seaf_warning ("Failed to index file blocks"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, */ +/* "Failed to index blocks"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - rawdata_to_hex(sha1, hex, 20); - new_dent = seaf_dirent_new (dir_version_from_repo_version(repo->version), - hex, STD_FILE_MODE, file_name, - (gint64)time(NULL), user, file_size); +/* rawdata_to_hex(sha1, hex, 20); */ +/* new_dent = seaf_dirent_new (dir_version_from_repo_version(repo->version), */ +/* hex, STD_FILE_MODE, file_name, */ +/* (gint64)time(NULL), user, file_size); */ - root_id = do_post_file_replace (repo, head_commit->root_id, - canon_path, replace_existed, new_dent); - if (!root_id) { - seaf_warning ("[post-blks] Failed to post file to %s in repo %s.\n", - canon_path, repo->id); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, - "Failed to put file"); - ret = -1; - goto out; - } +/* root_id = do_post_file_replace (repo, head_commit->root_id, */ +/* canon_path, replace_existed, new_dent); */ +/* if (!root_id) { */ +/* seaf_warning ("[post-blks] Failed to post file to %s in repo %s.\n", */ +/* canon_path, repo->id); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, */ +/* "Failed to put file"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - *new_id = g_strdup(hex); - snprintf(buf, SEAF_PATH_MAX, "Added \"%s\"", file_name); - if (gen_new_commit (repo_id, head_commit, root_id, - user, buf, NULL, error) < 0) - ret = -1; +/* *new_id = g_strdup(hex); */ +/* snprintf(buf, SEAF_PATH_MAX, "Added \"%s\"", file_name); */ +/* if (gen_new_commit (repo_id, head_commit, root_id, */ +/* user, buf, NULL, error) < 0) */ +/* ret = -1; */ -out: - if (repo) - seaf_repo_unref (repo); - if (head_commit) - seaf_commit_unref(head_commit); - string_list_free (blockids); - string_list_free (paths); - seaf_dirent_free (new_dent); - g_free (root_id); - g_free (canon_path); +/* out: */ +/* if (repo) */ +/* seaf_repo_unref (repo); */ +/* if (head_commit) */ +/* seaf_commit_unref(head_commit); */ +/* string_list_free (blockids); */ +/* string_list_free (paths); */ +/* seaf_dirent_free (new_dent); */ +/* g_free (root_id); */ +/* g_free (canon_path); */ - if (ret == 0) - update_repo_size(repo_id); +/* if (ret == 0) */ +/* update_repo_size(repo_id); */ - return ret; -} +/* return ret; */ +/* } */ int seaf_repo_manager_post_blocks (SeafRepoManager *mgr, @@ -4021,148 +4021,148 @@ out: return ret; } -int -seaf_repo_manager_put_file_blocks (SeafRepoManager *mgr, - const char *repo_id, - const char *parent_dir, - const char *file_name, - const char *blockids_json, - const char *paths_json, - const char *user, - const char *head_id, - gint64 file_size, - char **new_file_id, - GError **error) -{ - SeafRepo *repo = NULL; - SeafCommit *head_commit = NULL; - char *canon_path = NULL; - unsigned char sha1[20]; - char buf[SEAF_PATH_MAX]; - char *root_id = NULL; - SeafDirent *new_dent = NULL; - char hex[41]; - GList *blockids = NULL, *paths = NULL, *ptr; - char *old_file_id = NULL, *fullpath = NULL; - int ret = 0; +/* int */ +/* seaf_repo_manager_put_file_blocks (SeafRepoManager *mgr, */ +/* const char *repo_id, */ +/* const char *parent_dir, */ +/* const char *file_name, */ +/* const char *blockids_json, */ +/* const char *paths_json, */ +/* const char *user, */ +/* const char *head_id, */ +/* gint64 file_size, */ +/* char **new_file_id, */ +/* GError **error) */ +/* { */ +/* SeafRepo *repo = NULL; */ +/* SeafCommit *head_commit = NULL; */ +/* char *canon_path = NULL; */ +/* unsigned char sha1[20]; */ +/* char buf[SEAF_PATH_MAX]; */ +/* char *root_id = NULL; */ +/* SeafDirent *new_dent = NULL; */ +/* char hex[41]; */ +/* GList *blockids = NULL, *paths = NULL, *ptr; */ +/* char *old_file_id = NULL, *fullpath = NULL; */ +/* int ret = 0; */ - blockids = json_to_file_list (blockids_json); - paths = json_to_file_list (paths_json); - if (g_list_length(blockids) != g_list_length(paths)) { - seaf_warning ("[put-blks] Invalid blockids or paths.\n"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid files"); - ret = -1; - goto out; - } +/* blockids = json_to_file_list (blockids_json); */ +/* paths = json_to_file_list (paths_json); */ +/* if (g_list_length(blockids) != g_list_length(paths)) { */ +/* seaf_warning ("[put-blks] Invalid blockids or paths.\n"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid files"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - for (ptr = paths; ptr; ptr = ptr->next) { - char *temp_file_path = ptr->data; - if (g_access (temp_file_path, R_OK) != 0) { - seaf_warning ("[put-blks] File block %s doesn't exist or not readable.\n", - temp_file_path); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Invalid input file"); - ret = -1; - goto out; - } - } +/* for (ptr = paths; ptr; ptr = ptr->next) { */ +/* char *temp_file_path = ptr->data; */ +/* if (g_access (temp_file_path, R_OK) != 0) { */ +/* seaf_warning ("[put-blks] File block %s doesn't exist or not readable.\n", */ +/* temp_file_path); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Invalid input file"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ +/* } */ - GET_REPO_OR_FAIL(repo, repo_id); - const char *base = head_id ? head_id : repo->head->commit_id; - GET_COMMIT_OR_FAIL(head_commit, repo->id, repo->version, base); +/* GET_REPO_OR_FAIL(repo, repo_id); */ +/* const char *base = head_id ? head_id : repo->head->commit_id; */ +/* GET_COMMIT_OR_FAIL(head_commit, repo->id, repo->version, base); */ - if (!canon_path) - canon_path = get_canonical_path (parent_dir); +/* if (!canon_path) */ +/* canon_path = get_canonical_path (parent_dir); */ - if (should_ignore_file (file_name, NULL)) { - seaf_warning ("[put-blks] Invalid filename %s.\n", file_name); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Invalid filename"); - ret = -1; - goto out; - } +/* if (should_ignore_file (file_name, NULL)) { */ +/* seaf_warning ("[put-blks] Invalid filename %s.\n", file_name); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Invalid filename"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - if (strstr (parent_dir, "//") != NULL) { - seaf_warning ("[put-blks] parent_dir cantains // sequence.\n"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, - "Invalid parent dir"); - ret = -1; - goto out; - } +/* if (strstr (parent_dir, "//") != NULL) { */ +/* seaf_warning ("[put-blks] parent_dir cantains // sequence.\n"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, */ +/* "Invalid parent dir"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - FAIL_IF_FILE_NOT_EXISTS(repo->store_id, repo->version, - head_commit->root_id, canon_path, file_name, NULL); +/* FAIL_IF_FILE_NOT_EXISTS(repo->store_id, repo->version, */ +/* head_commit->root_id, canon_path, file_name, NULL); */ - /* Write blocks. */ - if (seaf_fs_manager_index_file_blocks (seaf->fs_mgr, - repo->store_id, repo->version, - paths, - blockids, sha1, file_size) < 0) { - seaf_warning ("failed to index blocks"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, - "Failed to index blocks"); - ret = -1; - goto out; - } +/* /\* Write blocks. *\/ */ +/* if (seaf_fs_manager_index_file_blocks (seaf->fs_mgr, */ +/* repo->store_id, repo->version, */ +/* paths, */ +/* blockids, sha1, file_size) < 0) { */ +/* seaf_warning ("failed to index blocks"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, */ +/* "Failed to index blocks"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - rawdata_to_hex(sha1, hex, 20); - new_dent = seaf_dirent_new (dir_version_from_repo_version(repo->version), - hex, STD_FILE_MODE, file_name, - (gint64)time(NULL), user, file_size); +/* rawdata_to_hex(sha1, hex, 20); */ +/* new_dent = seaf_dirent_new (dir_version_from_repo_version(repo->version), */ +/* hex, STD_FILE_MODE, file_name, */ +/* (gint64)time(NULL), user, file_size); */ - if (!fullpath) - fullpath = g_build_filename(parent_dir, file_name, NULL); +/* if (!fullpath) */ +/* fullpath = g_build_filename(parent_dir, file_name, NULL); */ - old_file_id = seaf_fs_manager_path_to_obj_id (seaf->fs_mgr, - repo->store_id, repo->version, - head_commit->root_id, - fullpath, NULL, NULL); +/* old_file_id = seaf_fs_manager_path_to_obj_id (seaf->fs_mgr, */ +/* repo->store_id, repo->version, */ +/* head_commit->root_id, */ +/* fullpath, NULL, NULL); */ - if (g_strcmp0(old_file_id, new_dent->id) == 0) { - if (new_file_id) - *new_file_id = g_strdup(new_dent->id); - goto out; - } +/* if (g_strcmp0(old_file_id, new_dent->id) == 0) { */ +/* if (new_file_id) */ +/* *new_file_id = g_strdup(new_dent->id); */ +/* goto out; */ +/* } */ - root_id = do_put_file (repo, head_commit->root_id, canon_path, new_dent); - if (!root_id) { - seaf_warning ("[put-blks] Failed to put file.\n"); - g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, - "Failed to put file"); - ret = -1; - goto out; - } +/* root_id = do_put_file (repo, head_commit->root_id, canon_path, new_dent); */ +/* if (!root_id) { */ +/* seaf_warning ("[put-blks] Failed to put file.\n"); */ +/* g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, */ +/* "Failed to put file"); */ +/* ret = -1; */ +/* goto out; */ +/* } */ - /* Commit. */ - snprintf(buf, SEAF_PATH_MAX, "Modified \"%s\"", file_name); - if (gen_new_commit (repo_id, head_commit, root_id, user, buf, NULL, error) < 0) { - ret = -1; - goto out; - } +/* /\* Commit. *\/ */ +/* snprintf(buf, SEAF_PATH_MAX, "Modified \"%s\"", file_name); */ +/* if (gen_new_commit (repo_id, head_commit, root_id, user, buf, NULL, error) < 0) { */ +/* ret = -1; */ +/* goto out; */ +/* } */ - if (new_file_id) - *new_file_id = g_strdup(new_dent->id); +/* if (new_file_id) */ +/* *new_file_id = g_strdup(new_dent->id); */ -out: - if (repo) - seaf_repo_unref (repo); - if (head_commit) - seaf_commit_unref(head_commit); - string_list_free (blockids); - string_list_free (paths); - seaf_dirent_free (new_dent); - g_free (root_id); - g_free (canon_path); - g_free (old_file_id); - g_free (fullpath); +/* out: */ +/* if (repo) */ +/* seaf_repo_unref (repo); */ +/* if (head_commit) */ +/* seaf_commit_unref(head_commit); */ +/* string_list_free (blockids); */ +/* string_list_free (paths); */ +/* seaf_dirent_free (new_dent); */ +/* g_free (root_id); */ +/* g_free (canon_path); */ +/* g_free (old_file_id); */ +/* g_free (fullpath); */ - if (ret == 0) { - update_repo_size (repo_id); - } +/* if (ret == 0) { */ +/* update_repo_size (repo_id); */ +/* } */ - return ret; -} +/* return ret; */ +/* } */ /* split filename into base and extension */ static void diff --git a/server/seaf-server.c b/server/seaf-server.c index 3fcaeea..86cd917 100644 --- a/server/seaf-server.c +++ b/server/seaf-server.c @@ -205,10 +205,10 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode) "seafile_post_file", searpc_signature_int__string_string_string_string_string()); - searpc_server_register_function ("seafserv-threaded-rpcserver", - seafile_post_file_blocks, - "seafile_post_file_blocks", - searpc_signature_string__string_string_string_string_string_string_int64_int()); + /* searpc_server_register_function ("seafserv-threaded-rpcserver", */ + /* seafile_post_file_blocks, */ + /* "seafile_post_file_blocks", */ + /* searpc_signature_string__string_string_string_string_string_string_int64_int()); */ searpc_server_register_function ("seafserv-threaded-rpcserver", seafile_post_multi_files, "seafile_post_multi_files", @@ -218,10 +218,10 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode) seafile_put_file, "seafile_put_file", searpc_signature_string__string_string_string_string_string_string()); - searpc_server_register_function ("seafserv-threaded-rpcserver", - seafile_put_file_blocks, - "seafile_put_file_blocks", - searpc_signature_string__string_string_string_string_string_string_string_int64()); + /* searpc_server_register_function ("seafserv-threaded-rpcserver", */ + /* seafile_put_file_blocks, */ + /* "seafile_put_file_blocks", */ + /* searpc_signature_string__string_string_string_string_string_string_string_int64()); */ searpc_server_register_function ("seafserv-threaded-rpcserver", seafile_post_empty_file, diff --git a/server/upload-file.c b/server/upload-file.c index 467dc57..1759f2c 100644 --- a/server/upload-file.c +++ b/server/upload-file.c @@ -700,7 +700,7 @@ upload_blks_api_cb(evhtp_request_t *req, void *arg) const char *parent_dir, *file_name, *size_str, *replace_str, *commitonly_str; GError *error = NULL; int error_code = ERROR_INTERNAL; - char *blockids_json, *tmp_files_json; + char *blockids_json; gint64 file_size = -1; int replace = 0; @@ -725,64 +725,68 @@ upload_blks_api_cb(evhtp_request_t *req, void *arg) size_str = g_hash_table_lookup (fsm->form_kvs, "file_size"); if (size_str) file_size = atoll(size_str); + commitonly_str = evhtp_kv_find (req->uri->query, "commitonly"); if (!file_name || !parent_dir || !size_str || file_size < 0) { seaf_debug ("[upload-blks] No parent dir or file name given.\n"); send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); return; } + if (!commitonly_str) { + send_error_reply (req, EVHTP_RES_BADREQ, "Only commit suppported.\n"); + return; + } if (!check_parent_dir (req, fsm->repo_id, parent_dir)) return; char *new_file_id = NULL; int rc = 0; - commitonly_str = evhtp_kv_find (req->uri->query, "commitonly"); - if (!commitonly_str) { - gint64 content_len = get_content_length (req); - if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, - fsm->repo_id, - content_len) != 0) { - error_code = ERROR_QUOTA; - goto error; - } + /* if (!commitonly_str) { */ + /* gint64 content_len = get_content_length (req); */ + /* if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, */ + /* fsm->repo_id, */ + /* content_len) != 0) { */ + /* error_code = ERROR_QUOTA; */ + /* goto error; */ + /* } */ - if (!check_tmp_file_list (fsm->files, &error_code)) - goto error; - blockids_json = file_list_to_json (fsm->filenames); - tmp_files_json = file_list_to_json (fsm->files); + /* if (!check_tmp_file_list (fsm->files, &error_code)) */ + /* goto error; */ + /* blockids_json = file_list_to_json (fsm->filenames); */ + /* tmp_files_json = file_list_to_json (fsm->files); */ - rc = seaf_repo_manager_post_file_blocks (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - file_name, - blockids_json, - tmp_files_json, - fsm->user, - file_size, - replace, - &new_file_id, - &error); - g_free (blockids_json); - g_free (tmp_files_json); - } else { - blockids_json = g_hash_table_lookup (fsm->form_kvs, "blockids"); - if (blockids_json == NULL) { - seaf_debug ("[upload-blks] No blockids given.\n"); - send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); - return; - } - rc = seaf_repo_manager_commit_file_blocks (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - file_name, - blockids_json, - fsm->user, - file_size, - replace, - &new_file_id, - &error); + /* rc = seaf_repo_manager_post_file_blocks (seaf->repo_mgr, */ + /* fsm->repo_id, */ + /* parent_dir, */ + /* file_name, */ + /* blockids_json, */ + /* tmp_files_json, */ + /* fsm->user, */ + /* file_size, */ + /* replace, */ + /* &new_file_id, */ + /* &error); */ + /* g_free (blockids_json); */ + /* g_free (tmp_files_json); */ + /* } else { */ + + blockids_json = g_hash_table_lookup (fsm->form_kvs, "blockids"); + if (blockids_json == NULL) { + seaf_debug ("[upload-blks] No blockids given.\n"); + send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); + return; } + rc = seaf_repo_manager_commit_file_blocks (seaf->repo_mgr, + fsm->repo_id, + parent_dir, + file_name, + blockids_json, + fsm->user, + file_size, + replace, + &new_file_id, + &error); if (rc < 0) { if (error) { if (error->code == POST_FILE_ERR_FILENAME) { @@ -838,118 +842,118 @@ error: } } -static void -upload_blks_ajax_cb(evhtp_request_t *req, void *arg) -{ - RecvFSM *fsm = arg; - char *parent_dir, *file_name, *size_str; - GError *error = NULL; - int error_code = ERROR_INTERNAL; - char *blockids_json, *tmp_files_json; - gint64 file_size = -1; +/* static void */ +/* upload_blks_ajax_cb(evhtp_request_t *req, void *arg) */ +/* { */ +/* RecvFSM *fsm = arg; */ +/* char *parent_dir, *file_name, *size_str; */ +/* GError *error = NULL; */ +/* int error_code = ERROR_INTERNAL; */ +/* char *blockids_json, *tmp_files_json; */ +/* gint64 file_size = -1; */ - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Allow-Headers", - "x-requested-with, content-type, accept, origin, authorization", 1, 1)); - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Allow-Methods", - "GET, POST, PUT, PATCH, DELETE, OPTIONS", 1, 1)); - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Allow-Origin", - "*", 1, 1)); - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Max-Age", - "86400", 1, 1)); +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Allow-Headers", */ +/* "x-requested-with, content-type, accept, origin, authorization", 1, 1)); */ +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Allow-Methods", */ +/* "GET, POST, PUT, PATCH, DELETE, OPTIONS", 1, 1)); */ +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Allow-Origin", */ +/* "*", 1, 1)); */ +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Max-Age", */ +/* "86400", 1, 1)); */ - if (evhtp_request_get_method(req) == htp_method_OPTIONS) { - /* If CORS preflight header, then create an empty body response (200 OK) - * and return it. - */ - send_success_reply (req); - return; - } +/* if (evhtp_request_get_method(req) == htp_method_OPTIONS) { */ +/* /\* If CORS preflight header, then create an empty body response (200 OK) */ +/* * and return it. */ +/* *\/ */ +/* send_success_reply (req); */ +/* return; */ +/* } */ - /* After upload_headers_cb() returns an error, libevhtp may still - * receive data from the web browser and call into this cb. - * In this case fsm will be NULL. - */ - if (!fsm || fsm->state == RECV_ERROR) - return; +/* /\* After upload_headers_cb() returns an error, libevhtp may still */ +/* * receive data from the web browser and call into this cb. */ +/* * In this case fsm will be NULL. */ +/* *\/ */ +/* if (!fsm || fsm->state == RECV_ERROR) */ +/* return; */ - parent_dir = g_hash_table_lookup (fsm->form_kvs, "parent_dir"); - file_name = g_hash_table_lookup (fsm->form_kvs, "file_name"); - size_str = g_hash_table_lookup (fsm->form_kvs, "file_size"); - if (size_str) - file_size = atoll(size_str); - if (!file_name || !parent_dir || !size_str || file_size < 0) { - seaf_debug ("[upload-blks] No parent dir or file name given.\n"); - send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); - return; - } +/* parent_dir = g_hash_table_lookup (fsm->form_kvs, "parent_dir"); */ +/* file_name = g_hash_table_lookup (fsm->form_kvs, "file_name"); */ +/* size_str = g_hash_table_lookup (fsm->form_kvs, "file_size"); */ +/* if (size_str) */ +/* file_size = atoll(size_str); */ +/* if (!file_name || !parent_dir || !size_str || file_size < 0) { */ +/* seaf_debug ("[upload-blks] No parent dir or file name given.\n"); */ +/* send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); */ +/* return; */ +/* } */ - if (!check_parent_dir (req, fsm->repo_id, parent_dir)) - return; +/* if (!check_parent_dir (req, fsm->repo_id, parent_dir)) */ +/* return; */ - if (!check_tmp_file_list (fsm->files, &error_code)) - goto error; +/* if (!check_tmp_file_list (fsm->files, &error_code)) */ +/* goto error; */ - gint64 content_len = get_content_length (req); - if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, - fsm->repo_id, - content_len) != 0) { - error_code = ERROR_QUOTA; - goto error; - } +/* gint64 content_len = get_content_length (req); */ +/* if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, */ +/* fsm->repo_id, */ +/* content_len) != 0) { */ +/* error_code = ERROR_QUOTA; */ +/* goto error; */ +/* } */ - blockids_json = file_list_to_json (fsm->filenames); - tmp_files_json = file_list_to_json (fsm->files); +/* blockids_json = file_list_to_json (fsm->filenames); */ +/* tmp_files_json = file_list_to_json (fsm->files); */ - int rc = seaf_repo_manager_post_file_blocks (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - file_name, - blockids_json, - tmp_files_json, - fsm->user, - file_size, - 0, - NULL, - &error); - g_free (blockids_json); - g_free (tmp_files_json); - if (rc < 0) { - if (error) { - if (error->code == POST_FILE_ERR_FILENAME) { - error_code = ERROR_FILENAME; - } - g_clear_error (&error); - } - goto error; - } +/* int rc = seaf_repo_manager_post_file_blocks (seaf->repo_mgr, */ +/* fsm->repo_id, */ +/* parent_dir, */ +/* file_name, */ +/* blockids_json, */ +/* tmp_files_json, */ +/* fsm->user, */ +/* file_size, */ +/* 0, */ +/* NULL, */ +/* &error); */ +/* g_free (blockids_json); */ +/* g_free (tmp_files_json); */ +/* if (rc < 0) { */ +/* if (error) { */ +/* if (error->code == POST_FILE_ERR_FILENAME) { */ +/* error_code = ERROR_FILENAME; */ +/* } */ +/* g_clear_error (&error); */ +/* } */ +/* goto error; */ +/* } */ - send_success_reply (req); - return; +/* send_success_reply (req); */ +/* return; */ -error: - switch (error_code) { - case ERROR_FILENAME: - send_error_reply (req, SEAF_HTTP_RES_BADFILENAME, "Invalid filename."); - break; - case ERROR_EXISTS: - send_error_reply (req, SEAF_HTTP_RES_EXISTS, "File already exists."); - break; - case ERROR_SIZE: - send_error_reply (req, SEAF_HTTP_RES_TOOLARGE, "File size is too large."); - break; - case ERROR_QUOTA: - send_error_reply (req, SEAF_HTTP_RES_NOQUOTA, "Out of quota."); - break; - case ERROR_RECV: - case ERROR_INTERNAL: - send_error_reply (req, EVHTP_RES_SERVERR, "Internal error.\n"); - break; - } -} +/* error: */ +/* switch (error_code) { */ +/* case ERROR_FILENAME: */ +/* send_error_reply (req, SEAF_HTTP_RES_BADFILENAME, "Invalid filename."); */ +/* break; */ +/* case ERROR_EXISTS: */ +/* send_error_reply (req, SEAF_HTTP_RES_EXISTS, "File already exists."); */ +/* break; */ +/* case ERROR_SIZE: */ +/* send_error_reply (req, SEAF_HTTP_RES_TOOLARGE, "File size is too large."); */ +/* break; */ +/* case ERROR_QUOTA: */ +/* send_error_reply (req, SEAF_HTTP_RES_NOQUOTA, "Out of quota."); */ +/* break; */ +/* case ERROR_RECV: */ +/* case ERROR_INTERNAL: */ +/* send_error_reply (req, EVHTP_RES_SERVERR, "Internal error.\n"); */ +/* break; */ +/* } */ +/* } */ /* Handle AJAX file upload. @@ -1276,11 +1280,10 @@ update_blks_api_cb(evhtp_request_t *req, void *arg) RecvFSM *fsm = arg; char *target_file, *parent_dir = NULL, *filename = NULL, *size_str = NULL; const char *commitonly_str; - const char *head_id = NULL; GError *error = NULL; int error_code = ERROR_INTERNAL; char *new_file_id = NULL; - char *blockids_json, *tmp_files_json; + char *blockids_json; gint64 file_size = -1; if (!fsm || fsm->state == RECV_ERROR) @@ -1293,6 +1296,11 @@ update_blks_api_cb(evhtp_request_t *req, void *arg) send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); return; } + commitonly_str = evhtp_kv_find (req->uri->query, "commitonly"); + if (!commitonly_str) { + send_error_reply (req, EVHTP_RES_BADREQ, "Only commit supported.\n"); + return; + } parent_dir = g_path_get_dirname (target_file); filename = g_path_get_basename (target_file); @@ -1300,55 +1308,52 @@ update_blks_api_cb(evhtp_request_t *req, void *arg) if (!check_parent_dir (req, fsm->repo_id, parent_dir)) return; - head_id = evhtp_kv_find (req->uri->query, "head"); - int rc = 0; - commitonly_str = evhtp_kv_find (req->uri->query, "commitonly"); - if (!commitonly_str) { - gint64 content_len = get_content_length(req); - if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, - fsm->repo_id, - content_len) != 0) { - error_code = ERROR_QUOTA; - goto error; - } + /* if (!commitonly_str) { */ + /* gint64 content_len = get_content_length(req); */ + /* if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, */ + /* fsm->repo_id, */ + /* content_len) != 0) { */ + /* error_code = ERROR_QUOTA; */ + /* goto error; */ + /* } */ - if (!check_tmp_file_list (fsm->files, &error_code)) - goto error; + /* if (!check_tmp_file_list (fsm->files, &error_code)) */ + /* goto error; */ - blockids_json = file_list_to_json (fsm->filenames); - tmp_files_json = file_list_to_json (fsm->files); - rc = seaf_repo_manager_put_file_blocks (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - filename, - blockids_json, - tmp_files_json, - fsm->user, - head_id, - file_size, - &new_file_id, - &error); - g_free (blockids_json); - g_free (tmp_files_json); - } else { - blockids_json = g_hash_table_lookup (fsm->form_kvs, "blockids"); - if (blockids_json == NULL) { - seaf_debug ("[upload-blks] No blockids given.\n"); - send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); - return; - } - rc = seaf_repo_manager_commit_file_blocks (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - filename, - blockids_json, - fsm->user, - file_size, - 1, - &new_file_id, - &error); + /* blockids_json = file_list_to_json (fsm->filenames); */ + /* tmp_files_json = file_list_to_json (fsm->files); */ + /* rc = seaf_repo_manager_put_file_blocks (seaf->repo_mgr, */ + /* fsm->repo_id, */ + /* parent_dir, */ + /* filename, */ + /* blockids_json, */ + /* tmp_files_json, */ + /* fsm->user, */ + /* head_id, */ + /* file_size, */ + /* &new_file_id, */ + /* &error); */ + /* g_free (blockids_json); */ + /* g_free (tmp_files_json); */ + /* } else { */ + + blockids_json = g_hash_table_lookup (fsm->form_kvs, "blockids"); + if (blockids_json == NULL) { + seaf_debug ("[upload-blks] No blockids given.\n"); + send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); + return; } + rc = seaf_repo_manager_commit_file_blocks (seaf->repo_mgr, + fsm->repo_id, + parent_dir, + filename, + blockids_json, + fsm->user, + file_size, + 1, + &new_file_id, + &error); g_free (parent_dir); g_free (filename); @@ -1396,124 +1401,124 @@ error: } } -static void -update_blks_ajax_cb(evhtp_request_t *req, void *arg) -{ - RecvFSM *fsm = arg; - char *target_file, *parent_dir = NULL, *filename = NULL, *size_str = NULL; - const char *head_id = NULL; - GError *error = NULL; - int error_code = ERROR_INTERNAL; - char *blockids_json, *tmp_files_json; - gint64 file_size = -1; +/* static void */ +/* update_blks_ajax_cb(evhtp_request_t *req, void *arg) */ +/* { */ +/* RecvFSM *fsm = arg; */ +/* char *target_file, *parent_dir = NULL, *filename = NULL, *size_str = NULL; */ +/* const char *head_id = NULL; */ +/* GError *error = NULL; */ +/* int error_code = ERROR_INTERNAL; */ +/* char *blockids_json, *tmp_files_json; */ +/* gint64 file_size = -1; */ - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Allow-Headers", - "x-requested-with, content-type, accept, origin, authorization", 1, 1)); - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Allow-Methods", - "GET, POST, PUT, PATCH, DELETE, OPTIONS", 1, 1)); - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Allow-Origin", - "*", 1, 1)); - evhtp_headers_add_header (req->headers_out, - evhtp_header_new("Access-Control-Max-Age", - "86400", 1, 1)); +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Allow-Headers", */ +/* "x-requested-with, content-type, accept, origin, authorization", 1, 1)); */ +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Allow-Methods", */ +/* "GET, POST, PUT, PATCH, DELETE, OPTIONS", 1, 1)); */ +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Allow-Origin", */ +/* "*", 1, 1)); */ +/* evhtp_headers_add_header (req->headers_out, */ +/* evhtp_header_new("Access-Control-Max-Age", */ +/* "86400", 1, 1)); */ - if (evhtp_request_get_method(req) == htp_method_OPTIONS) { - /* If CORS preflight header, then create an empty body response (200 OK) - * and return it. - */ - send_success_reply (req); - return; - } +/* if (evhtp_request_get_method(req) == htp_method_OPTIONS) { */ +/* /\* If CORS preflight header, then create an empty body response (200 OK) */ +/* * and return it. */ +/* *\/ */ +/* send_success_reply (req); */ +/* return; */ +/* } */ - if (!fsm || fsm->state == RECV_ERROR) - return; - target_file = g_hash_table_lookup (fsm->form_kvs, "target_file"); - size_str = g_hash_table_lookup (fsm->form_kvs, "file_size"); - if (size_str) file_size = atoll(size_str); - if (!target_file || !size_str || file_size < 0) { - seaf_debug ("[Update-blks] No target file given.\n"); - send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); - return; - } +/* if (!fsm || fsm->state == RECV_ERROR) */ +/* return; */ +/* target_file = g_hash_table_lookup (fsm->form_kvs, "target_file"); */ +/* size_str = g_hash_table_lookup (fsm->form_kvs, "file_size"); */ +/* if (size_str) file_size = atoll(size_str); */ +/* if (!target_file || !size_str || file_size < 0) { */ +/* seaf_debug ("[Update-blks] No target file given.\n"); */ +/* send_error_reply (req, EVHTP_RES_BADREQ, "Invalid URL.\n"); */ +/* return; */ +/* } */ - parent_dir = g_path_get_dirname (target_file); - filename = g_path_get_basename (target_file); +/* parent_dir = g_path_get_dirname (target_file); */ +/* filename = g_path_get_basename (target_file); */ - if (!check_parent_dir (req, fsm->repo_id, parent_dir)) - return; +/* if (!check_parent_dir (req, fsm->repo_id, parent_dir)) */ +/* return; */ - if (!check_tmp_file_list (fsm->files, &error_code)) - goto error; +/* if (!check_tmp_file_list (fsm->files, &error_code)) */ +/* goto error; */ - head_id = evhtp_kv_find (req->uri->query, "head"); +/* head_id = evhtp_kv_find (req->uri->query, "head"); */ - gint64 content_len = get_content_length (req); - if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, - fsm->repo_id, - content_len) != 0) { - error_code = ERROR_QUOTA; - goto error; - } +/* gint64 content_len = get_content_length (req); */ +/* if (seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, */ +/* fsm->repo_id, */ +/* content_len) != 0) { */ +/* error_code = ERROR_QUOTA; */ +/* goto error; */ +/* } */ - blockids_json = file_list_to_json (fsm->filenames); - tmp_files_json = file_list_to_json (fsm->files); - int rc = seaf_repo_manager_put_file_blocks (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - filename, - blockids_json, - tmp_files_json, - fsm->user, - head_id, - file_size, - NULL, - &error); - g_free (blockids_json); - g_free (tmp_files_json); - g_free (parent_dir); - g_free (filename); +/* blockids_json = file_list_to_json (fsm->filenames); */ +/* tmp_files_json = file_list_to_json (fsm->files); */ +/* int rc = seaf_repo_manager_put_file_blocks (seaf->repo_mgr, */ +/* fsm->repo_id, */ +/* parent_dir, */ +/* filename, */ +/* blockids_json, */ +/* tmp_files_json, */ +/* fsm->user, */ +/* head_id, */ +/* file_size, */ +/* NULL, */ +/* &error); */ +/* g_free (blockids_json); */ +/* g_free (tmp_files_json); */ +/* g_free (parent_dir); */ +/* g_free (filename); */ - if (rc < 0) { - if (error) { - if (g_strcmp0 (error->message, "file does not exist") == 0) { - error_code = ERROR_NOT_EXIST; - } - g_clear_error (&error); - } - goto error; - } +/* if (rc < 0) { */ +/* if (error) { */ +/* if (g_strcmp0 (error->message, "file does not exist") == 0) { */ +/* error_code = ERROR_NOT_EXIST; */ +/* } */ +/* g_clear_error (&error); */ +/* } */ +/* goto error; */ +/* } */ - send_success_reply (req); +/* send_success_reply (req); */ - return; +/* return; */ -error: - switch (error_code) { - case ERROR_FILENAME: - send_error_reply (req, SEAF_HTTP_RES_BADFILENAME, "Invalid filename.\n"); - break; - case ERROR_EXISTS: - send_error_reply (req, SEAF_HTTP_RES_EXISTS, "File already exists.\n"); - break; - case ERROR_SIZE: - send_error_reply (req, SEAF_HTTP_RES_TOOLARGE, "File size is too large.\n"); - break; - case ERROR_QUOTA: - send_error_reply (req, SEAF_HTTP_RES_NOQUOTA, "Out of quota.\n"); - break; - case ERROR_NOT_EXIST: - send_error_reply (req, SEAF_HTTP_RES_NOT_EXISTS, "File does not exist.\n"); - break; - case ERROR_RECV: - case ERROR_INTERNAL: - default: - send_error_reply (req, EVHTP_RES_SERVERR, "Internal error.\n"); - break; - } -} +/* error: */ +/* switch (error_code) { */ +/* case ERROR_FILENAME: */ +/* send_error_reply (req, SEAF_HTTP_RES_BADFILENAME, "Invalid filename.\n"); */ +/* break; */ +/* case ERROR_EXISTS: */ +/* send_error_reply (req, SEAF_HTTP_RES_EXISTS, "File already exists.\n"); */ +/* break; */ +/* case ERROR_SIZE: */ +/* send_error_reply (req, SEAF_HTTP_RES_TOOLARGE, "File size is too large.\n"); */ +/* break; */ +/* case ERROR_QUOTA: */ +/* send_error_reply (req, SEAF_HTTP_RES_NOQUOTA, "Out of quota.\n"); */ +/* break; */ +/* case ERROR_NOT_EXIST: */ +/* send_error_reply (req, SEAF_HTTP_RES_NOT_EXISTS, "File does not exist.\n"); */ +/* break; */ +/* case ERROR_RECV: */ +/* case ERROR_INTERNAL: */ +/* default: */ +/* send_error_reply (req, EVHTP_RES_SERVERR, "Internal error.\n"); */ +/* break; */ +/* } */ +/* } */ static char * format_update_json_ret (const char *filename, const char *file_id, gint64 size) @@ -2351,8 +2356,8 @@ upload_file_init (evhtp_t *htp, const char *http_temp_dir) cb = evhtp_set_regex_cb (htp, "^/upload-blks-api/.*", upload_blks_api_cb, NULL); evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); - cb = evhtp_set_regex_cb (htp, "^/upload-blks-aj/.*", upload_blks_ajax_cb, NULL); - evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); + /* cb = evhtp_set_regex_cb (htp, "^/upload-blks-aj/.*", upload_blks_ajax_cb, NULL); */ + /* evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); */ cb = evhtp_set_regex_cb (htp, "^/upload-aj/.*", upload_ajax_cb, NULL); evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); @@ -2366,8 +2371,8 @@ upload_file_init (evhtp_t *htp, const char *http_temp_dir) cb = evhtp_set_regex_cb (htp, "^/update-blks-api/.*", update_blks_api_cb, NULL); evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); - cb = evhtp_set_regex_cb (htp, "^/update-blks-aj/.*", update_blks_ajax_cb, NULL); - evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); + /* cb = evhtp_set_regex_cb (htp, "^/update-blks-aj/.*", update_blks_ajax_cb, NULL); */ + /* evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); */ cb = evhtp_set_regex_cb (htp, "^/update-aj/.*", update_ajax_cb, NULL); evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);