pupload namespace
This commit is contained in:
parent
5bb00db4f7
commit
d147b8fa8b
|
|
@ -290,7 +290,7 @@ static void delete_local_folder_from_db(psync_folderid_t localfolderid,
|
|||
psync_sql_query("SELECT id FROM localfile WHERE localparentfolderid=?");
|
||||
psync_sql_bind_uint(res, 1, localfolderid);
|
||||
while ((row = psync_sql_fetch_rowint(res)))
|
||||
psync_delete_upload_tasks_for_file(row[0]);
|
||||
pupload_del_tasks(row[0]);
|
||||
psync_sql_free_result(res);
|
||||
res = psync_sql_prep_statement(
|
||||
"DELETE FROM localfile WHERE localparentfolderid=?");
|
||||
|
|
@ -1333,7 +1333,7 @@ static void task_del_folder_rec_do(const char *localpath,
|
|||
psync_sql_bind_uint(res, 1, localfolderid);
|
||||
psync_sql_bind_uint(res, 2, syncid);
|
||||
while ((vrow = psync_sql_fetch_row(res))) {
|
||||
psync_delete_upload_tasks_for_file(psync_get_number(vrow[0]));
|
||||
pupload_del_tasks(psync_get_number(vrow[0]));
|
||||
nm = psync_strcat(localpath, "/",
|
||||
psync_get_string(vrow[1]), NULL);
|
||||
debug(D_NOTICE, "deleting %s", nm);
|
||||
|
|
|
|||
|
|
@ -798,7 +798,7 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
buff = psync_malloc(PSYNC_COPY_BUFFER_SIZE);
|
||||
if (usize) {
|
||||
asize = usize;
|
||||
psync_upload_add_bytes_uploaded(asize);
|
||||
pupload_bytes_add(asize);
|
||||
}
|
||||
while (usize < fsize) {
|
||||
if (unlikely(stop_current_upload)) {
|
||||
|
|
@ -817,7 +817,7 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
if (unlikely_log(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
goto err2;
|
||||
asize += rrd;
|
||||
psync_upload_add_bytes_uploaded(rrd);
|
||||
pupload_bytes_add(rrd);
|
||||
}
|
||||
psync_free(buff);
|
||||
pfile_close(fd);
|
||||
|
|
@ -856,7 +856,7 @@ static int large_upload_creat(uint64_t taskid, psync_folderid_t folderid,
|
|||
goto errs;
|
||||
}
|
||||
if (asize) {
|
||||
psync_upload_sub_bytes_uploaded(asize);
|
||||
pupload_bytes_sub(asize);
|
||||
}
|
||||
return large_upload_save(api, uploadid, folderid, name, taskid, writeid, 1, 0,
|
||||
key, filename);
|
||||
|
|
@ -866,7 +866,7 @@ ret0:
|
|||
psync_apipool_release(api);
|
||||
perm_fail_upload_task(taskid);
|
||||
if (asize)
|
||||
psync_upload_sub_bytes_uploaded(asize);
|
||||
pupload_bytes_sub(asize);
|
||||
return 0;
|
||||
err2:
|
||||
psync_free(buff);
|
||||
|
|
@ -876,7 +876,7 @@ err0:
|
|||
psync_apipool_release_bad(api);
|
||||
errs:
|
||||
if (asize)
|
||||
psync_upload_sub_bytes_uploaded(asize);
|
||||
pupload_bytes_sub(asize);
|
||||
return PRINT_RETURN(-1);
|
||||
}
|
||||
|
||||
|
|
@ -899,7 +899,7 @@ static int upload_modify_send_copy_from(psock_t *api,
|
|||
return PSYNC_NET_TEMPFAIL;
|
||||
else {
|
||||
*upl += length;
|
||||
psync_upload_add_bytes_uploaded(length);
|
||||
pupload_bytes_add(length);
|
||||
return PSYNC_NET_OK;
|
||||
}
|
||||
}
|
||||
|
|
@ -945,7 +945,7 @@ static int upload_modify_send_local(psock_t *api,
|
|||
if (unlikely_log(psync_socket_writeall_upload(api, buff, rrd) != rrd))
|
||||
goto err0;
|
||||
*upl += rrd;
|
||||
psync_upload_add_bytes_uploaded(rrd);
|
||||
pupload_bytes_add(rrd);
|
||||
}
|
||||
psync_free(buff);
|
||||
return PSYNC_NET_OK;
|
||||
|
|
@ -1114,7 +1114,7 @@ int upload_modify(uint64_t taskid, psync_folderid_t folderid, const char *name,
|
|||
goto err2;
|
||||
}
|
||||
psync_interval_tree_free(tree);
|
||||
psync_upload_sub_bytes_uploaded(asize);
|
||||
pupload_bytes_sub(asize);
|
||||
if (psync_fs_get_file_writeid(taskid) != writeid) {
|
||||
debug(D_NOTICE, "%s changed while uploading as %lu/%s", filename,
|
||||
(unsigned long)folderid, name);
|
||||
|
|
@ -1129,7 +1129,7 @@ err2:
|
|||
psync_apipool_release_bad(api);
|
||||
err1:
|
||||
psync_interval_tree_free(tree);
|
||||
psync_upload_sub_bytes_uploaded(asize);
|
||||
pupload_bytes_sub(asize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1197,7 +1197,7 @@ static void large_upload() {
|
|||
else
|
||||
uploadid = 0;
|
||||
psync_sql_free_result(res);
|
||||
psync_upload_inc_uploads();
|
||||
pupload_inc();
|
||||
if (type == PSYNC_FS_TASK_CREAT)
|
||||
ret = large_upload_creat(taskid, folderid, name, filename, uploadid,
|
||||
writeid, key);
|
||||
|
|
@ -1213,7 +1213,7 @@ static void large_upload() {
|
|||
psync_sql_run_free(res);
|
||||
pstatus_upload_recalc_async();
|
||||
}
|
||||
psync_upload_dec_uploads();
|
||||
pupload_dec();
|
||||
if (ret) {
|
||||
res = psync_sql_query_rdlock("SELECT type FROM fstask WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, taskid);
|
||||
|
|
@ -1324,7 +1324,7 @@ static int psync_send_task_creat(psock_t *api, fsupload_task_t *task) {
|
|||
ret = psync_send_task_creat_upload_small(api, task, fd, &st);
|
||||
pfile_close(fd);
|
||||
if (!ret) {
|
||||
psync_upload_inc_uploads();
|
||||
pupload_inc();
|
||||
task->ccreat = 1;
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -1933,7 +1933,7 @@ static void psync_fsupload_process_tasks(psync_list *tasks) {
|
|||
psync_sql_commit_transaction();
|
||||
|
||||
if (creats) {
|
||||
psync_upload_dec_uploads_cnt(creats);
|
||||
pupload_dec_by(creats);
|
||||
pstatus_upload_recalc_async();
|
||||
} else if (cancels || dels)
|
||||
pstatus_upload_recalc_async();
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ static void scan_upload_file(sync_folderlist *fl) {
|
|||
debug(D_NOTICE, "file created %s", fl->name);
|
||||
/* it is possible that files that are reported as new are already uploading
|
||||
* -- is it? when? how? and with what localid?
|
||||
psync_delete_upload_tasks_for_file(fl->localid);
|
||||
pupload_del_tasks(fl->localid);
|
||||
*/
|
||||
res = psync_sql_prep_statement(
|
||||
"INSERT OR IGNORE INTO localfile (localparentfolderid, syncid, size, "
|
||||
|
|
@ -698,7 +698,7 @@ static void scan_upload_modified_file(sync_folderlist *fl) {
|
|||
psync_sql_res *res;
|
||||
debug(D_NOTICE, "file modified %s (%lu)", fl->name,
|
||||
(unsigned long)fl->localid);
|
||||
psync_delete_upload_tasks_for_file(fl->localid);
|
||||
pupload_del_tasks(fl->localid);
|
||||
res = psync_sql_prep_statement("UPDATE localfile SET size=?, inode=?, "
|
||||
"mtime=?, mtimenative=? WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, fl->size);
|
||||
|
|
@ -732,7 +732,7 @@ static void scan_delete_file(sync_folderlist *fl) {
|
|||
return;
|
||||
}
|
||||
psync_sql_free_result(res);
|
||||
psync_delete_upload_tasks_for_file(fl->localid);
|
||||
pupload_del_tasks(fl->localid);
|
||||
res = psync_sql_prep_statement("DELETE FROM localfile WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, fl->localid);
|
||||
psync_sql_run_free(res);
|
||||
|
|
@ -895,7 +895,7 @@ static void delete_local_folder_rec(psync_folderid_t localfolderid) {
|
|||
res = psync_sql_query("SELECT id FROM localfile WHERE localparentfolderid=?");
|
||||
psync_sql_bind_uint(res, 1, localfolderid);
|
||||
while ((row = psync_sql_fetch_rowint(res)))
|
||||
psync_delete_upload_tasks_for_file(row[0]);
|
||||
pupload_del_tasks(row[0]);
|
||||
psync_sql_free_result(res);
|
||||
res = psync_sql_prep_statement(
|
||||
"DELETE FROM localfile WHERE localparentfolderid=?");
|
||||
|
|
@ -1168,7 +1168,7 @@ restart:
|
|||
psync_sql_commit_transaction();
|
||||
|
||||
if (w) {
|
||||
psync_wake_upload();
|
||||
pupload_wake();
|
||||
pstatus_upload_recalc_async();
|
||||
}
|
||||
for (i = 0; i < SCAN_LIST_CNT; i++)
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ void psync_start_sync(pstatus_change_callback_t status_callback,
|
|||
pqevent_process(event_callback);
|
||||
psyncer_init();
|
||||
pdiff_init();
|
||||
psync_upload_init();
|
||||
pupload_init();
|
||||
pdownload_init();
|
||||
psync_netlibs_init();
|
||||
psync_localscan_init();
|
||||
|
|
@ -450,7 +450,7 @@ void psync_logout2(uint32_t auth_status, int doinvauth) {
|
|||
pstatus_set(PSTATUS_TYPE_AUTH, auth_status);
|
||||
psync_fs_pause_until_login();
|
||||
pdownload_stop_all();
|
||||
psync_stop_all_upload();
|
||||
pupload_stop_all();
|
||||
ptask_stop_async();
|
||||
pcache_clean();
|
||||
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
|
||||
|
|
@ -548,7 +548,7 @@ void psync_unlink() {
|
|||
unlinked = 1;
|
||||
tfa = 0;
|
||||
pdownload_stop_all();
|
||||
psync_stop_all_upload();
|
||||
pupload_stop_all();
|
||||
// Stop the root backup folder before unlinking the database. 0 means fetch
|
||||
// the deviceid from local DB.
|
||||
psync_stop_device(0, &errMsg);
|
||||
|
|
@ -958,7 +958,7 @@ int psync_change_synctype(psync_syncid_t syncid, psync_synctype_t synctype) {
|
|||
psync_localnotify_del_sync(syncid);
|
||||
psync_restat_sync_folders_del(syncid);
|
||||
pdownload_stop_sync(syncid);
|
||||
psync_stop_sync_upload(syncid);
|
||||
pupload_stop_sync(syncid);
|
||||
psync_sql_sync();
|
||||
ppathstatus_reload_syncs();
|
||||
psyncer_create(syncid);
|
||||
|
|
@ -1007,7 +1007,7 @@ int psync_delete_sync(psync_syncid_t syncid) {
|
|||
return -1;
|
||||
else {
|
||||
pdownload_stop_sync(syncid);
|
||||
psync_stop_sync_upload(syncid);
|
||||
pupload_stop_sync(syncid);
|
||||
psync_localnotify_del_sync(syncid);
|
||||
psync_restat_sync_folders_del(syncid);
|
||||
psync_restart_localscan();
|
||||
|
|
|
|||
|
|
@ -965,7 +965,7 @@ void ptask_upload(psync_syncid_t syncid, psync_fileid_t localfileid, const char
|
|||
psync_sql_bind_uint(res, 4, localfileid);
|
||||
psync_sql_bind_string(res, 5, name);
|
||||
psync_sql_run_free(res);
|
||||
psync_wake_upload();
|
||||
pupload_wake();
|
||||
pstatus_upload_recalc_async();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,14 +99,14 @@ static const uint32_t requiredstatuses[] = {
|
|||
PSTATUS_COMBINE(PSTATUS_TYPE_ONLINE, PSTATUS_ONLINE_ONLINE),
|
||||
PSTATUS_COMBINE(PSTATUS_TYPE_ACCFULL, PSTATUS_ACCFULL_QUOTAOK)};
|
||||
|
||||
void psync_upload_inc_uploads() {
|
||||
void pupload_inc() {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
psync_status.filesuploading++;
|
||||
pthread_mutex_unlock(&upload_mutex);
|
||||
pstatus_send_status_update();
|
||||
}
|
||||
|
||||
void psync_upload_dec_uploads() {
|
||||
void pupload_dec() {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
psync_status.filesuploading--;
|
||||
if (psync_status.filesuploading == 0 && current_uploads_waiters)
|
||||
|
|
@ -114,7 +114,7 @@ void psync_upload_dec_uploads() {
|
|||
pthread_mutex_unlock(&upload_mutex);
|
||||
pstatus_send_status_update();
|
||||
}
|
||||
void psync_upload_dec_uploads_cnt(uint32_t cnt) {
|
||||
void pupload_dec_by(uint32_t cnt) {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
psync_status.filesuploading -= cnt;
|
||||
if (psync_status.filesuploading == 0 && current_uploads_waiters)
|
||||
|
|
@ -123,14 +123,14 @@ void psync_upload_dec_uploads_cnt(uint32_t cnt) {
|
|||
pstatus_send_status_update();
|
||||
}
|
||||
|
||||
void psync_upload_add_bytes_uploaded(uint64_t bytes) {
|
||||
void pupload_bytes_add(uint64_t bytes) {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
psync_status.bytesuploaded += bytes;
|
||||
pthread_mutex_unlock(&upload_mutex);
|
||||
pstatus_send_status_update();
|
||||
}
|
||||
|
||||
void psync_upload_sub_bytes_uploaded(uint64_t bytes) {
|
||||
void pupload_bytes_sub(uint64_t bytes) {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
psync_status.bytesuploaded -= bytes;
|
||||
pthread_mutex_unlock(&upload_mutex);
|
||||
|
|
@ -1563,7 +1563,7 @@ static void task_run_upload_file_thread(void *ptr) {
|
|||
res = psync_sql_prep_statement("UPDATE task SET inprogress=0 WHERE id=?");
|
||||
psync_sql_bind_uint(res, 1, ut->upllist.taskid);
|
||||
psync_sql_run_free(res);
|
||||
psync_wake_upload();
|
||||
pupload_wake();
|
||||
} else
|
||||
delete_upload_task(ut->upllist.taskid, ut->upllist.localfileid);
|
||||
pthread_mutex_lock(¤t_uploads_mutex);
|
||||
|
|
@ -1753,19 +1753,19 @@ static void upload_thread() {
|
|||
}
|
||||
}
|
||||
|
||||
void psync_wake_upload() {
|
||||
void pupload_wake() {
|
||||
pthread_mutex_lock(&upload_mutex);
|
||||
if (!upload_wakes++)
|
||||
pthread_cond_signal(&upload_cond);
|
||||
pthread_mutex_unlock(&upload_mutex);
|
||||
}
|
||||
|
||||
void psync_upload_init() {
|
||||
ptimer_exception_handler(psync_wake_upload);
|
||||
void pupload_init() {
|
||||
ptimer_exception_handler(pupload_wake);
|
||||
prun_thread("upload main", upload_thread);
|
||||
}
|
||||
|
||||
void psync_delete_upload_tasks_for_file(psync_fileid_t localfileid) {
|
||||
void pupload_del_tasks(psync_fileid_t localfileid) {
|
||||
psync_sql_res *res;
|
||||
upload_list_t *upl;
|
||||
res = psync_sql_prep_statement(
|
||||
|
|
@ -1783,7 +1783,7 @@ void psync_delete_upload_tasks_for_file(psync_fileid_t localfileid) {
|
|||
pthread_mutex_unlock(¤t_uploads_mutex);
|
||||
}
|
||||
|
||||
void psync_stop_sync_upload(psync_syncid_t syncid) {
|
||||
void pupload_stop_sync(psync_syncid_t syncid) {
|
||||
upload_list_t *upl;
|
||||
psync_sql_res *res;
|
||||
|
||||
|
|
@ -1802,7 +1802,7 @@ void psync_stop_sync_upload(psync_syncid_t syncid) {
|
|||
pstatus_upload_recalc_async();
|
||||
}
|
||||
|
||||
void psync_stop_all_upload() {
|
||||
void pupload_stop_all() {
|
||||
upload_list_t *upl;
|
||||
pthread_mutex_lock(¤t_uploads_mutex);
|
||||
psync_list_for_each_element(upl, &uploads, upload_list_t, list) upl->stop = 1;
|
||||
|
|
|
|||
|
|
@ -32,17 +32,19 @@
|
|||
#ifndef _PSYNC_UPLOAD_H
|
||||
#define _PSYNC_UPLOAD_H
|
||||
|
||||
#include "psynclib.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void psync_upload_init();
|
||||
void psync_upload_inc_uploads();
|
||||
void psync_upload_dec_uploads();
|
||||
void psync_upload_dec_uploads_cnt(uint32_t cnt);
|
||||
void psync_upload_add_bytes_uploaded(uint64_t bytes);
|
||||
void psync_upload_sub_bytes_uploaded(uint64_t bytes);
|
||||
void psync_wake_upload();
|
||||
void psync_delete_upload_tasks_for_file(psync_fileid_t localfileid);
|
||||
void psync_stop_sync_upload(psync_syncid_t syncid);
|
||||
void psync_stop_all_upload();
|
||||
#include "pfoldersync.h"
|
||||
|
||||
void pupload_init();
|
||||
void pupload_inc();
|
||||
void pupload_dec();
|
||||
void pupload_dec_by(uint32_t cnt);
|
||||
void pupload_bytes_add(uint64_t bytes);
|
||||
void pupload_bytes_sub(uint64_t bytes);
|
||||
void pupload_wake();
|
||||
void pupload_del_tasks(psync_fileid_t localfileid);
|
||||
void pupload_stop_sync(psync_syncid_t syncid);
|
||||
void pupload_stop_all();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue