Skip to content

Commit c52f5ed

Browse files
author
virco
committed
fixes
1 parent 2e37244 commit c52f5ed

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

pupload.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,13 @@ static void set_local_file_conflicted(psync_fileid_t localfileid, psync_fileid_t
377377

378378
static int copy_file(psync_fileid_t fileid, uint64_t hash, psync_folderid_t folderid, const char *name, psync_fileid_t localfileid){
379379
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;
381380
binresult *res;
382381
const binresult *meta;
383382
uint64_t result;
384-
api=psync_apipool_get();
385-
if (unlikely(!api))
386-
return -1;
387383
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)){
392386
psync_diff_unlock();
393-
psync_apipool_release_bad(api);
394387
return -1;
395388
}
396389
result=psync_find_result(res, "result", PARAM_NUM)->num;
@@ -966,6 +959,24 @@ static void delete_uploadids(psync_fileid_t localfileid){
966959
psync_free(rows);
967960
}
968961

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+
969980
static int task_uploadfile(psync_syncid_t syncid, psync_folderid_t localfileid, const char *name, upload_list_t *upload){
970981
psync_sql_res *res;
971982
psync_uint_row row;
@@ -1042,14 +1053,12 @@ static int task_uploadfile(psync_syncid_t syncid, psync_folderid_t localfileid,
10421053
ret=psync_get_local_file_checksum_part(localpath, hashhex, &fsize, phashhex, ufsize);
10431054
else
10441055
ret=psync_get_local_file_checksum(localpath, hashhex, &fsize);
1045-
if (ret){
1056+
if (unlikely(ret)){
10461057
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);
10501058
psync_unlock_file(lock);
10511059
psync_free(nname);
10521060
psync_free(localpath);
1061+
delete_from_localfile(localfileid);
10531062
return 0;
10541063
}
10551064
if (fsize!=upload->filesize){

0 commit comments

Comments
 (0)