Skip to content

Commit 11a0f4b

Browse files
author
Ivan Stoev
committed
Merge branch 'master' of gitlab.pcloud.com:pcloud/synclib
2 parents 3230af8 + d944ded commit 11a0f4b

File tree

13 files changed

+1092
-71
lines changed

13 files changed

+1092
-71
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif
3737
OBJ=pcompat.o psynclib.o plocks.o plibs.o pcallbacks.o pdiff.o pstatus.o papi.o ptimer.o pupload.o pdownload.o pfolder.o\
3838
psyncer.o ptasks.o psettings.o pnetlibs.o pcache.o pscanner.o plist.o plocalscan.o plocalnotify.o pp2p.o\
3939
pcrypto.o pssl.o pfileops.o ptree.o ppassword.o prunratelimit.o pmemlock.o pnotifications.o pexternalstatus.o publiclinks.o\
40-
pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o poverlay_mac.o poverlay_win.o pcompression.o pasyncnet.o
40+
pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o poverlay_mac.o poverlay_win.o pcompression.o pasyncnet.o ppathstatus.o
4141

4242
OBJFS=pfs.o ppagecache.o pfsfolder.o pfstasks.o pfsupload.o pintervaltree.o pfsxattr.o pcloudcrypto.o pfscrypto.o pcrc32c.o pfsstatic.o plocks.o
4343

pdiff.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "publiclinks.h"
4949
#include "pcontacts.h"
5050
#include "pcloudcrypto.h"
51+
#include "ppathstatus.h"
5152
#include <ctype.h>
5253

5354

@@ -170,7 +171,7 @@ static psync_socket *get_connected_socket(){
170171
auth=user=pass=NULL;
171172
psync_is_business = 0;
172173
int digest = 1;
173-
while (1){
174+
while (1){
174175
psync_free(auth);
175176
psync_free(user);
176177
psync_free(pass);
@@ -255,7 +256,7 @@ static psync_socket *get_connected_socket(){
255256
digest = 0;
256257
continue;
257258
}
258-
259+
259260
else
260261
psync_milisleep(PSYNC_SLEEP_BEFORE_RECONNECT);
261262
continue;
@@ -632,6 +633,7 @@ static void process_modifyfolder(const binresult *entry){
632633
psync_sql_bind_uint(res, 1, mtime);
633634
psync_sql_bind_uint(res, 2, parentfolderid);
634635
psync_sql_run_free(res);
636+
psync_path_status_folder_moved(folderid, oldparentfolderid, parentfolderid);
635637
}
636638
/* We should check if oldparentfolderid is in downloadlist, not folderid. If parentfolderid is not in and
637639
* folderid is in, it means that folder that is a "root" of a syncid is modified, we do not care about that.
@@ -745,6 +747,7 @@ static void process_deletefolder(const binresult *entry){
745747
}
746748
meta=psync_find_result(entry, "metadata", PARAM_HASH);
747749
folderid=psync_find_result(meta, "folderid", PARAM_NUM)->num;
750+
psync_path_status_folder_deleted(folderid);
748751
if (psync_is_folder_in_downloadlist(folderid)){
749752
psync_del_folder_from_downloadlist(folderid);
750753
res=psync_sql_query("SELECT syncid, localfolderid FROM syncedfolder WHERE folderid=?");
@@ -1966,6 +1969,7 @@ static uint64_t process_entries(const binresult *entries, uint64_t newdiffid){
19661969
psync_set_uint_value("usedquota", used_quota);
19671970
//update_ba_emails();
19681971
//update_ba_teams();
1972+
psync_path_status_clear_path_cache();
19691973
psync_sql_commit_transaction();
19701974
psync_diff_unlock();
19711975
if (needdownload){

pfstasks.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "pfolder.h"
3636
#include "pfs.h"
3737
#include "pcloudcrypto.h"
38+
#include "ppathstatus.h"
3839
#include <string.h>
3940
#include <stddef.h>
4041
#include <stdio.h>
@@ -386,6 +387,8 @@ int psync_fstask_mkdir(psync_fsfolderid_t folderid, const char *name, uint32_t f
386387
psync_fstask_release_folder_tasks_locked(folder);
387388
if (!depend)
388389
psync_fsupload_wake();
390+
if (folderid>=0)
391+
psync_path_status_drive_folder_changed(folderid);
389392
return 0;
390393
}
391394

@@ -609,6 +612,8 @@ psync_fstask_creat_t *psync_fstask_add_creat(psync_fstask_folder_t *folder, cons
609612
memcpy(task->name, name, len);
610613
psync_fstask_insert_into_tree(&folder->creats, offsetof(psync_fstask_creat_t, name), &task->tree);
611614
folder->taskscnt+=2;
615+
if (folder->folderid>=0)
616+
psync_path_status_drive_folder_changed(folder->folderid);
612617
return task;
613618
}
614619

@@ -667,6 +672,8 @@ psync_fstask_creat_t *psync_fstask_add_modified_file(psync_fstask_folder_t *fold
667672
task->fileid=-(psync_fsfileid_t)taskid;
668673
memcpy(task->name, name, len);
669674
psync_fstask_insert_into_tree(&folder->creats, offsetof(psync_fstask_creat_t, name), &task->tree);
675+
if (folder->folderid>=0)
676+
psync_path_status_drive_folder_changed(folder->folderid);
670677
folder->taskscnt+=2;
671678
return task;
672679
}
@@ -1007,6 +1014,8 @@ int psync_fstask_rename_file(psync_fsfileid_t fileid, psync_fsfolderid_t parentf
10071014
psync_fsupload_wake();
10081015
if (fileid>0 && parentfolderid>=0)
10091016
add_history_record(fileid, parentfolderid, name);
1017+
if (folder->folderid>=0)
1018+
psync_path_status_drive_folder_changed(folder->folderid);
10101019
return 0;
10111020
}
10121021

@@ -1173,6 +1182,8 @@ int psync_fstask_rename_folder(psync_fsfolderid_t folderid, psync_fsfolderid_t p
11731182
folder->taskscnt+=2;
11741183
psync_fstask_release_folder_tasks_locked(folder);
11751184
psync_fsupload_wake();
1185+
if (to_folderid>=0)
1186+
psync_path_status_drive_folder_changed(to_folderid);
11761187
return 0;
11771188
}
11781189

@@ -1189,13 +1200,16 @@ static int folder_cmp(const psync_tree *t1, const psync_tree *t2){
11891200
void psync_fstask_folder_created(psync_folderid_t parentfolderid, uint64_t taskid, psync_folderid_t folderid, const char *name){
11901201
psync_fstask_folder_t *folder;
11911202
psync_fstask_mkdir_t *mk;
1203+
int pchg;
1204+
pchg=0;
11921205
folder=psync_fstask_get_folder_tasks_locked(parentfolderid);
11931206
if (folder){
11941207
mk=psync_fstask_find_mkdir(folder, name, taskid);
11951208
if (mk){
11961209
psync_tree_del(&folder->mkdirs, &mk->tree);
11971210
psync_free(mk);
11981211
folder->taskscnt--;
1212+
pchg=1;
11991213
}
12001214
psync_fstask_release_folder_tasks_locked(folder);
12011215
}
@@ -1230,7 +1244,10 @@ void psync_fstask_folder_created(psync_folderid_t parentfolderid, uint64_t taski
12301244
folder->folderid=folderid;
12311245
psync_tree_add(&folders, &folder->tree, folder_cmp);
12321246
psync_fstask_release_folder_tasks_locked(folder);
1247+
psync_path_status_drive_folder_changed(folderid);
12331248
}
1249+
if (pchg)
1250+
psync_path_status_drive_folder_changed(parentfolderid);
12341251
}
12351252

12361253
void psync_fstask_folder_deleted(psync_folderid_t parentfolderid, uint64_t taskid, const char *name){
@@ -1298,6 +1315,8 @@ void psync_fstask_file_created(psync_folderid_t parentfolderid, uint64_t taskid,
12981315
else
12991316
debug(D_NOTICE, "could not find unlink for file %s in folderid %lu", name, (unsigned long)parentfolderid);
13001317
psync_fstask_release_folder_tasks_locked(folder);
1318+
if (cr)
1319+
psync_path_status_drive_folder_changed(parentfolderid);
13011320
}
13021321
else
13031322
debug(D_NOTICE, "could not find unlink for file %s in folderid %lu", name, (unsigned long)parentfolderid);
@@ -1324,6 +1343,8 @@ void psync_fstask_file_modified(psync_folderid_t parentfolderid, uint64_t taskid
13241343
folder->taskscnt--;
13251344
}
13261345
psync_fstask_release_folder_tasks_locked(folder);
1346+
if (cr)
1347+
psync_path_status_drive_folder_changed(parentfolderid);
13271348
}
13281349
if (!folder || !cr)
13291350
psync_fstask_look_for_creat_in_db(parentfolderid, taskid, name, fileid);
@@ -1365,6 +1386,8 @@ void psync_fstask_file_renamed(psync_folderid_t folderid, uint64_t taskid, const
13651386
folder->taskscnt--;
13661387
}
13671388
psync_fstask_release_folder_tasks_locked(folder);
1389+
if (cr)
1390+
psync_path_status_drive_folder_changed(folderid);
13681391
}
13691392
res=psync_sql_query("SELECT id, folderid, text1 FROM fstask WHERE id=?");
13701393
psync_sql_bind_uint(res, 1, frtaskid);
@@ -1412,6 +1435,8 @@ void psync_fstask_folder_renamed(psync_folderid_t parentfolderid, uint64_t taski
14121435
folder->taskscnt--;
14131436
}
14141437
psync_fstask_release_folder_tasks_locked(folder);
1438+
if (mk)
1439+
psync_path_status_drive_folder_changed(parentfolderid);
14151440
}
14161441
res=psync_sql_query("SELECT id, folderid, text1 FROM fstask WHERE id=?");
14171442
psync_sql_bind_uint(res, 1, frtaskid);
@@ -1462,6 +1487,8 @@ static void psync_init_task_mkdir(psync_variant_row row){
14621487
psync_fstask_insert_into_tree(&folder->mkdirs, offsetof(psync_fstask_mkdir_t, name), &task->tree);
14631488
folder->taskscnt++;
14641489
psync_fstask_release_folder_tasks_locked(folder);
1490+
if (folderid>=0)
1491+
psync_path_status_drive_folder_changed(folderid);
14651492
}
14661493

14671494
static void psync_init_task_rmdir(psync_variant_row row){
@@ -1518,6 +1545,8 @@ static void psync_init_task_creat(psync_variant_row row){
15181545
psync_fstask_insert_into_tree(&folder->creats, offsetof(psync_fstask_creat_t, name), &task->tree);
15191546
folder->taskscnt+=2;
15201547
psync_fstask_release_folder_tasks_locked(folder);
1548+
if (folderid>=0)
1549+
psync_path_status_drive_folder_changed(folderid);
15211550
}
15221551

15231552

@@ -1613,6 +1642,8 @@ static void psync_init_task_renfile_to(psync_variant_row row){
16131642
folder->taskscnt+=2;
16141643
psync_fstask_release_folder_tasks_locked(folder);
16151644
psync_fs_rename_openfile_locked(cr->fileid, folderid, name);
1645+
if (folderid>=0)
1646+
psync_path_status_drive_folder_changed(folderid);
16161647
}
16171648

16181649
static void psync_init_task_renfolder_from(psync_variant_row row){
@@ -1665,6 +1696,8 @@ static void psync_init_task_renfolder_to(psync_variant_row row){
16651696
psync_fstask_insert_into_tree(&folder->mkdirs, offsetof(psync_fstask_mkdir_t, name), &mk->tree);
16661697
folder->taskscnt+=2;
16671698
psync_fstask_release_folder_tasks_locked(folder);
1699+
if (folderid>=0)
1700+
psync_path_status_drive_folder_changed(folderid);
16681701
}
16691702

16701703
static void psync_init_task_modify(psync_variant_row row){
@@ -1695,6 +1728,8 @@ static void psync_init_task_modify(psync_variant_row row){
16951728
memcpy(cr->name, name, len);
16961729
psync_fstask_insert_into_tree(&folder->creats, offsetof(psync_fstask_creat_t, name), &cr->tree);
16971730
folder->taskscnt+=2;
1731+
if (folder->folderid>=0)
1732+
psync_path_status_drive_folder_changed(folder->folderid);
16981733
psync_fstask_release_folder_tasks_locked(folder);
16991734
}
17001735

pfsupload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "pupload.h"
4141
#include "pfscrypto.h"
4242
#include "pcache.h"
43+
#include "ppathstatus.h"
4344
#include <string.h>
4445

4546
typedef struct {
@@ -390,7 +391,7 @@ static int save_meta(const binresult *meta, psync_folderid_t folderid, const cha
390391
return -1;
391392
}
392393
psync_sql_commit_transaction();
393-
debug(D_NOTICE, "file %lu/%s uploaded (mtime=%lu, size=%lu)", (unsigned long)folderid, name,
394+
debug(D_NOTICE, "file %lu/%s uploaded (mtime=%lu, size=%lu)", (unsigned long)folderid, name,
394395
(unsigned long)psync_find_result(meta, "modified", PARAM_NUM)->num,
395396
(unsigned long)psync_find_result(meta, "size", PARAM_NUM)->num);
396397
psync_status_recalc_to_upload_async();

0 commit comments

Comments
 (0)