Skip to content

Commit

Permalink
Merge branch 'poet' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
killing committed Jun 5, 2014
2 parents b598f82 + 5ad977c commit 671e364
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 29 deletions.
4 changes: 4 additions & 0 deletions common/rpc-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -2550,6 +2550,7 @@ seafile_post_file_blocks (const char *repo_id,
const char *paths_json,
const char *user,
gint64 file_size,
int replace_existed,
GError **error)
{
if (!repo_id || !parent_dir || !file_name
Expand All @@ -2573,6 +2574,7 @@ seafile_post_file_blocks (const char *repo_id,
paths_json,
user,
file_size,
replace_existed,
&new_id,
error) < 0) {
return NULL;
Expand All @@ -2587,6 +2589,7 @@ seafile_post_multi_files (const char *repo_id,
const char *filenames_json,
const char *paths_json,
const char *user,
int replace_existed,
GError **error)
{
if (!repo_id || !filenames_json || !parent_dir || !paths_json || !user) {
Expand All @@ -2607,6 +2610,7 @@ seafile_post_multi_files (const char *repo_id,
filenames_json,
paths_json,
user,
replace_existed,
&ret_json,
error) < 0) {
return NULL;
Expand Down
33 changes: 31 additions & 2 deletions httpserver/upload-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ upload_cb(evhtp_request_t *req, void *arg)
filenames_json,
tmp_files_json,
fsm->user,
0,
&error);
g_free (filenames_json);
g_free (tmp_files_json);
Expand Down Expand Up @@ -367,10 +368,11 @@ upload_api_cb(evhtp_request_t *req, void *arg)
{
RecvFSM *fsm = arg;
SearpcClient *rpc_client = NULL;
char *parent_dir;
char *parent_dir, *replace_str;
GError *error = NULL;
int error_code = ERROR_INTERNAL;
char *filenames_json, *tmp_files_json;
int replace = 0;

/* After upload_headers_cb() returns an error, libevhtp may still
* receive data from the web browser and call into this cb.
Expand All @@ -386,6 +388,17 @@ upload_api_cb(evhtp_request_t *req, void *arg)
return;
}

replace_str = g_hash_table_lookup (fsm->form_kvs, "replace");
if (replace_str) {
replace = atoi(replace_str);
if (replace != 0 && replace != 1) {
seaf_warning ("[Upload] Invalid argument replace: %s.\n", replace_str);
evbuffer_add_printf(req->buffer_out, "Invalid argument.\n");
set_content_length_header (req);
evhtp_send_reply (req, EVHTP_RES_BADREQ);
return;
}
}
parent_dir = g_hash_table_lookup (fsm->form_kvs, "parent_dir");
if (!parent_dir) {
seaf_warning ("[upload] No parent dir given.\n");
Expand Down Expand Up @@ -417,6 +430,7 @@ upload_api_cb(evhtp_request_t *req, void *arg)
filenames_json,
tmp_files_json,
fsm->user,
replace,
&error);
g_free (filenames_json);
g_free (tmp_files_json);
Expand Down Expand Up @@ -484,11 +498,12 @@ upload_blks_api_cb(evhtp_request_t *req, void *arg)
{
RecvFSM *fsm = arg;
SearpcClient *rpc_client = NULL;
char *parent_dir, *file_name, *size_str;
char *parent_dir, *file_name, *size_str, *replace_str;
GError *error = NULL;
int error_code = ERROR_INTERNAL;
char *blockids_json, *tmp_files_json;
gint64 file_size = -1;
int replace = 0;

/* After upload_headers_cb() returns an error, libevhtp may still
* receive data from the web browser and call into this cb.
Expand All @@ -497,6 +512,17 @@ upload_blks_api_cb(evhtp_request_t *req, void *arg)
if (!fsm || fsm->state == RECV_ERROR)
return;

replace_str = g_hash_table_lookup (fsm->form_kvs, "replace");
if (replace_str) {
replace = atoi(replace_str);
if (replace != 0 && replace != 1) {
seaf_warning ("[Upload-blks] Invalid argument replace: %s.\n", replace_str);
evbuffer_add_printf(req->buffer_out, "Invalid argument.\n");
set_content_length_header (req);
evhtp_send_reply (req, EVHTP_RES_BADREQ);
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");
Expand Down Expand Up @@ -534,6 +560,7 @@ upload_blks_api_cb(evhtp_request_t *req, void *arg)
tmp_files_json,
fsm->user,
file_size,
replace,
&error);
g_free (blockids_json);
g_free (tmp_files_json);
Expand Down Expand Up @@ -668,6 +695,7 @@ upload_blks_ajax_cb(evhtp_request_t *req, void *arg)
tmp_files_json,
fsm->user,
file_size,
0,
&error);
g_free (blockids_json);
g_free (tmp_files_json);
Expand Down Expand Up @@ -806,6 +834,7 @@ upload_ajax_cb(evhtp_request_t *req, void *arg)
filenames_json,
tmp_files_json,
fsm->user,
0,
&error);
g_free (filenames_json);
g_free (tmp_files_json);
Expand Down
2 changes: 2 additions & 0 deletions include/seafile-rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ seafile_post_multi_files (const char *repo_id,
const char *filenames_json,
const char *paths_json,
const char *user,
int replace,
GError **error);

/**
Expand All @@ -582,6 +583,7 @@ seafile_post_file_blocks (const char *repo_id,
const char *paths_json,
const char *user,
gint64 file_size,
int replace_existed,
GError **error);


Expand Down
2 changes: 2 additions & 0 deletions include/seafile.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ seafile_post_file_blocks (SearpcClient *client,
const char *paths_json,
const char *user,
gint64 file_size,
int replace_existed,
GError **error);

char *
Expand All @@ -141,6 +142,7 @@ seafile_post_multi_files (SearpcClient *client,
const char *filenames_json,
const char *paths_json,
const char *user,
int replace_existed,
GError **error);

int
Expand Down
2 changes: 2 additions & 0 deletions lib/rpc_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
[ "string", ["string", "string", "string", "string"] ],
[ "string", ["string", "string", "string", "string", "int"] ],
[ "string", ["string", "string", "string", "string", "string"] ],
[ "string", ["string", "string", "string", "string", "string", "int"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "int"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "int", "int"] ],
[ "string", ["string", "string", "string", "string", "string", "string"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "int64"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "int64", "int"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "string"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "string", "int64"] ],
[ "string", ["string", "string", "string", "string", "string", "string", "string", "string", "string"] ],
Expand Down
12 changes: 8 additions & 4 deletions lib/seafile-rpc-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,18 @@ seafile_post_file_blocks (SearpcClient *client,
const char *paths_json,
const char *user,
gint64 file_size,
int replace_existed,
GError **error)
{
return searpc_client_call__string (client, "seafile_post_file_blocks", error,
7, "string", repo_id,
8, "string", repo_id,
"string", parent_dir,
"string", file_name,
"string", blockids_json,
"string", paths_json,
"string", user,
"int64", &file_size);
"int64", &file_size,
"int", replace_existed);
}

char *
Expand All @@ -341,14 +343,16 @@ seafile_post_multi_files (SearpcClient *client,
const char *filenames_json,
const char *paths_json,
const char *user,
int replace_existed,
GError **error)
{
return searpc_client_call__string (client, "seafile_post_multi_files", error,
5, "string", repo_id,
6, "string", repo_id,
"string", parent_dir,
"string", filenames_json,
"string", paths_json,
"string", user);
"string", user,
"int", replace_existed);
}

int
Expand Down
2 changes: 2 additions & 0 deletions server/repo-mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ seaf_repo_manager_post_multi_files (SeafRepoManager *mgr,
const char *filenames_json,
const char *paths_json,
const char *user,
int replace_existed,
char **new_ids,
GError **error);

Expand All @@ -289,6 +290,7 @@ seaf_repo_manager_post_file_blocks (SeafRepoManager *mgr,
const char *paths_json,
const char *user,
gint64 file_size,
int replace_existed,
char **new_id,
GError **error);

Expand Down
Loading

0 comments on commit 671e364

Please sign in to comment.