mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-03 16:34:33 +00:00
Add rpc cancel_zip_task().
This commit is contained in:
@@ -2283,6 +2283,13 @@ seafile_query_zip_progress (const char *token, GError **error)
|
||||
token, error);
|
||||
}
|
||||
|
||||
int
|
||||
seafile_cancel_zip_task (const char *token, GError **error)
|
||||
{
|
||||
return zip_download_mgr_cancel_zip_task (seaf->zip_download_mgr,
|
||||
token);
|
||||
}
|
||||
|
||||
int
|
||||
seafile_add_share (const char *repo_id, const char *from_email,
|
||||
const char *to_email, const char *permission, GError **error)
|
||||
|
@@ -500,6 +500,9 @@ seafile_web_query_access_token (const char *token, GError **error);
|
||||
char *
|
||||
seafile_query_zip_progress (const char *token, GError **error);
|
||||
|
||||
int
|
||||
seafile_cancel_zip_task (const char *token, GError **error);
|
||||
|
||||
GObject *
|
||||
seafile_get_checkout_task (const char *repo_id, GError **error);
|
||||
|
||||
|
@@ -280,6 +280,10 @@ class SeafServerRpcClient(ccnet.RpcClientBase):
|
||||
pass
|
||||
query_zip_progress = seafile_query_zip_progress
|
||||
|
||||
@searpc_func("int", ["string"])
|
||||
def cancel_zip_task(token):
|
||||
pass
|
||||
|
||||
###### GC ####################
|
||||
@searpc_func("int", [])
|
||||
def seafile_gc():
|
||||
|
@@ -49,6 +49,9 @@ class SeafileAPI(object):
|
||||
"""
|
||||
return seafserv_rpc.query_zip_progress(token)
|
||||
|
||||
def cancel_zip_task(self, token):
|
||||
return seafserv_rpc.cancel_zip_task(token)
|
||||
|
||||
# password
|
||||
|
||||
def is_password_set(self, repo_id, username):
|
||||
|
@@ -326,6 +326,11 @@ archive_dir (PackDirData *data,
|
||||
}
|
||||
|
||||
for (ptr = dir->entries; ptr; ptr = ptr->next) {
|
||||
if (progress->canceled) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dent = ptr->data;
|
||||
if (S_ISREG(dent->mode)) {
|
||||
ret = add_file_to_archive (data, dirpath, dent);
|
||||
@@ -405,6 +410,8 @@ archive_multi (PackDirData *data, GList *dirent_list,
|
||||
SeafDirent *dirent;
|
||||
|
||||
for (iter = dirent_list; iter; iter = iter->next) {
|
||||
if (progress->canceled)
|
||||
return -1;
|
||||
dirent = iter->data;
|
||||
if (S_ISREG(dirent->mode)) {
|
||||
if (add_file_to_archive (data, "", dirent) < 0) {
|
||||
@@ -447,12 +454,18 @@ pack_files (const char *store_id,
|
||||
if (strcmp (dirname, "") != 0) {
|
||||
// Pack dir
|
||||
if (archive_dir (data, (char *)internal, "", progress) < 0) {
|
||||
seaf_warning ("Failed to archive dir.\n");
|
||||
if (progress->canceled)
|
||||
seaf_warning ("Zip task for dir %s canceled.\n", dirname);
|
||||
else
|
||||
seaf_warning ("Failed to archive dir %s.\n", dirname);
|
||||
ret = -1;
|
||||
}
|
||||
} else {
|
||||
// Pack multi
|
||||
if (archive_multi (data, (GList *)internal, progress) < 0) {
|
||||
if (progress->canceled)
|
||||
seaf_warning ("Archiving multi files canceled.\n");
|
||||
else
|
||||
seaf_warning ("Failed to archive multi files.\n");
|
||||
ret = -1;
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ typedef struct Progress {
|
||||
int total;
|
||||
char *zip_file_path;
|
||||
gint64 expire_ts;
|
||||
gboolean canceled;
|
||||
} Progress;
|
||||
|
||||
int
|
||||
|
@@ -591,6 +591,10 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
|
||||
seafile_query_zip_progress,
|
||||
"seafile_query_zip_progress",
|
||||
searpc_signature_string__string());
|
||||
searpc_server_register_function ("seafserv-rpcserver",
|
||||
seafile_cancel_zip_task,
|
||||
"cancel_zip_task",
|
||||
searpc_signature_int__string());
|
||||
|
||||
/* Copy task related. */
|
||||
|
||||
|
@@ -611,3 +611,14 @@ zip_download_mgr_del_zip_progress (ZipDownloadMgr *mgr,
|
||||
{
|
||||
remove_progress_by_token (mgr->priv, token);
|
||||
}
|
||||
|
||||
int
|
||||
zip_download_mgr_cancel_zip_task (ZipDownloadMgr *mgr,
|
||||
const char *token)
|
||||
{
|
||||
Progress *progress = get_progress_obj (mgr->priv, token);
|
||||
if (progress)
|
||||
progress->canceled = TRUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -30,4 +30,8 @@ void
|
||||
zip_download_mgr_del_zip_progress (ZipDownloadMgr *mgr,
|
||||
const char *token);
|
||||
|
||||
int
|
||||
zip_download_mgr_cancel_zip_task (ZipDownloadMgr *mgr,
|
||||
const char *token);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user