Skip to content

Commit aeba469

Browse files
author
virco
committed
fix
1 parent 2564188 commit aeba469

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pfsupload.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,41 @@ static void psync_fsupload_run_tasks(psync_list *tasks){
15761576
psync_milisleep(PSYNC_SLEEP_ON_FAILED_UPLOAD);
15771577
}
15781578

1579+
static void clean_stuck_tasks(){
1580+
psync_sql_res *res;
1581+
psync_full_result_int *fr;
1582+
uint64_t taskid;
1583+
const char *cachepath;
1584+
char *filename;
1585+
uint32_t i;
1586+
char fileidhex[sizeof(psync_fsfileid_t)*2+2];
1587+
cachepath=psync_setting_get_string(_PS(fscachepath));
1588+
res=psync_sql_query_rdlock("SELECT f.id FROM fstask f LEFT JOIN pagecachetask p ON f.id=p.taskid WHERE f.status=3");
1589+
fr=psync_sql_fetchall_int(res);
1590+
for (i=0; i<fr->rows; i++){
1591+
taskid=psync_get_result_cell(fr, i, 0);
1592+
psync_binhex(fileidhex, &taskid, sizeof(psync_fsfileid_t));
1593+
fileidhex[sizeof(psync_fsfileid_t)]='d';
1594+
fileidhex[sizeof(psync_fsfileid_t)+1]=0;
1595+
filename=psync_strcat(cachepath, PSYNC_DIRECTORY_SEPARATOR, fileidhex, NULL);
1596+
psync_file_delete(filename);
1597+
psync_free(filename);
1598+
fileidhex[sizeof(psync_fsfileid_t)]='i';
1599+
filename=psync_strcat(cachepath, PSYNC_DIRECTORY_SEPARATOR, fileidhex, NULL);
1600+
psync_file_delete(filename);
1601+
psync_free(filename);
1602+
psync_sql_start_transaction();
1603+
res=psync_sql_prep_statement("DELETE FROM fstaskdepend WHERE dependfstaskid=?");
1604+
psync_sql_bind_uint(res, 1, taskid);
1605+
psync_sql_run_free(res);
1606+
res=psync_sql_prep_statement("DELETE FROM fstask WHERE id=?");
1607+
psync_sql_bind_uint(res, 1, taskid);
1608+
psync_sql_run_free(res);
1609+
psync_sql_commit_transaction();
1610+
}
1611+
psync_free(fr);
1612+
}
1613+
15791614
static void psync_fsupload_check_tasks(){
15801615
fsupload_task_t *task;
15811616
psync_sql_res *res;
@@ -1641,6 +1676,7 @@ static void psync_fsupload_check_tasks(){
16411676
}
16421677

16431678
static void psync_fsupload_thread(){
1679+
clean_stuck_tasks();
16441680
while (psync_do_run){
16451681
psync_wait_statuses_array(requiredstatusesnooverquota, ARRAY_SIZE(requiredstatusesnooverquota));
16461682
// it is better to sleep a bit to give a chance to events to accumulate

0 commit comments

Comments
 (0)