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