@@ -377,20 +377,13 @@ static void set_local_file_conflicted(psync_fileid_t localfileid, psync_fileid_t
377
377
378
378
static int copy_file (psync_fileid_t fileid , uint64_t hash , psync_folderid_t folderid , const char * name , psync_fileid_t localfileid ){
379
379
binparam params []= {P_STR ("auth" , psync_my_auth ), P_NUM ("fileid" , fileid ), P_NUM ("hash" , hash ), P_NUM ("tofolderid" , folderid ), P_STR ("toname" , name )};
380
- psync_socket * api ;
381
380
binresult * res ;
382
381
const binresult * meta ;
383
382
uint64_t result ;
384
- api = psync_apipool_get ();
385
- if (unlikely (!api ))
386
- return -1 ;
387
383
psync_diff_lock ();
388
- res = send_command (api , "copyfile" , params );
389
- if (likely (res ))
390
- psync_apipool_release (api );
391
- else {
384
+ res = psync_api_run_command ("copyfile" , params );
385
+ if (unlikely (!res )){
392
386
psync_diff_unlock ();
393
- psync_apipool_release_bad (api );
394
387
return -1 ;
395
388
}
396
389
result = psync_find_result (res , "result" , PARAM_NUM )-> num ;
@@ -966,6 +959,24 @@ static void delete_uploadids(psync_fileid_t localfileid){
966
959
psync_free (rows );
967
960
}
968
961
962
+ static void delete_from_localfile (psync_fileid_t localfileid ){
963
+ psync_sql_res * res ;
964
+ psync_uint_row row ;
965
+ res = psync_sql_query ("SELECT syncid, localparentfolderid FROM localfile WHERE id=?" );
966
+ psync_sql_bind_uint (res , 1 , localfileid );
967
+ if ((row = psync_sql_fetch_rowint (res ))){
968
+ psync_syncid_t syncid = row [0 ];
969
+ psync_folderid_t folderid = row [1 ];
970
+ psync_sql_free_result (res );
971
+ res = psync_sql_prep_statement ("DELETE FROM localfile WHERE id=?" );
972
+ psync_sql_bind_uint (res , 1 , localfileid );
973
+ psync_sql_run_free (res );
974
+ psync_path_status_sync_folder_task_completed (syncid , folderid );
975
+ }
976
+ else
977
+ psync_sql_free_result (res );
978
+ }
979
+
969
980
static int task_uploadfile (psync_syncid_t syncid , psync_folderid_t localfileid , const char * name , upload_list_t * upload ){
970
981
psync_sql_res * res ;
971
982
psync_uint_row row ;
@@ -1042,14 +1053,12 @@ static int task_uploadfile(psync_syncid_t syncid, psync_folderid_t localfileid,
1042
1053
ret = psync_get_local_file_checksum_part (localpath , hashhex , & fsize , phashhex , ufsize );
1043
1054
else
1044
1055
ret = psync_get_local_file_checksum (localpath , hashhex , & fsize );
1045
- if (ret ){
1056
+ if (unlikely ( ret ) ){
1046
1057
debug (D_WARNING , "could not open local file %s, deleting it from localfile" , localpath );
1047
- res = psync_sql_prep_statement ("DELETE FROM localfile WHERE id=?" );
1048
- psync_sql_bind_uint (res , 1 , localfileid );
1049
- psync_sql_run_free (res );
1050
1058
psync_unlock_file (lock );
1051
1059
psync_free (nname );
1052
1060
psync_free (localpath );
1061
+ delete_from_localfile (localfileid );
1053
1062
return 0 ;
1054
1063
}
1055
1064
if (fsize != upload -> filesize ){
0 commit comments