@@ -1576,6 +1576,41 @@ static void psync_fsupload_run_tasks(psync_list *tasks){
1576
1576
psync_milisleep (PSYNC_SLEEP_ON_FAILED_UPLOAD );
1577
1577
}
1578
1578
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
+
1579
1614
static void psync_fsupload_check_tasks (){
1580
1615
fsupload_task_t * task ;
1581
1616
psync_sql_res * res ;
@@ -1641,6 +1676,7 @@ static void psync_fsupload_check_tasks(){
1641
1676
}
1642
1677
1643
1678
static void psync_fsupload_thread (){
1679
+ clean_stuck_tasks ();
1644
1680
while (psync_do_run ){
1645
1681
psync_wait_statuses_array (requiredstatusesnooverquota , ARRAY_SIZE (requiredstatusesnooverquota ));
1646
1682
// it is better to sleep a bit to give a chance to events to accumulate
0 commit comments