Skip to content

Commit 312a01f

Browse files
author
Ivan Stoev
committed
Merge master branch
2 parents 80204fb + 6d910c1 commit 312a01f

38 files changed

+2815
-382
lines changed

gitcommit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _GITCOMMIT_H
2+
#define _GITCOMMIT_H
3+
4+
#define GIT_PREV_COMMIT_ID "94bcb6bc2320e3a73c2e3fccbda649bd79421db7"
5+
#define GIT_PREV_COMMIT_DATE "2016-12-21 18:57:17 +0200"
6+
#define GIT_COMMIT_DATE "2016-12-22 01:29:14 +0200"
7+
8+
#endif

pCloudCC/lib/pclsync/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ USESSL=mbed
77
#CFLAGS=-Wall -Wpointer-arith -O2 -g -fsanitize=address -mtune=core2
88
CFLAGS=-Wall -Wpointer-arith -O2 -g -fno-stack-protector -fomit-frame-pointer -mtune=core2 -fPIC
99
#CFLAGS=-O2 -g -pg
10+
#CFLAGS=-Wall -Wpointer-arith -O2 -g -mtune=core2 -I../../psync32/zlib -I../../psync32/sqlite -m32 -D_FILE_OFFSET_BITS=64
1011

1112
#CMAKE whants lib extension
1213
LIB_A=libpsynclib.a
@@ -39,7 +40,8 @@ endif
3940
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\
4041
psyncer.o ptasks.o psettings.o pnetlibs.o pcache.o pscanner.o plist.o plocalscan.o plocalnotify.o pp2p.o\
4142
pcrypto.o pssl.o pfileops.o ptree.o ppassword.o prunratelimit.o pmemlock.o pnotifications.o pexternalstatus.o publiclinks.o\
42-
pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o poverlay_mac.o poverlay_win.o pcompression.o pasyncnet.o ppathstatus.o
43+
pbusinessaccount.o pcontacts.o poverlay.o poverlay_lin.o poverlay_mac.o poverlay_win.o pcompression.o pasyncnet.o ppathstatus.o\
44+
pdevice_monitor.o
4345

4446
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
4547

pCloudCC/lib/pclsync/pbusinessaccount.c

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void psync_update_cryptostatus(){
621621
uint64_t u, crexp, crsub = 0, is_business = 0;
622622
int crst = 0,crstat;
623623

624-
binparam params[] = { P_STR("auth", psync_my_auth) };
624+
binparam params[] = { P_STR("auth", psync_my_auth), P_STR("timeformat","timestamp") };
625625
res = psync_api_run_command("userinfo", params);
626626
if (!res) {
627627
debug(D_WARNING, "Send command returned invalid result.\n");
@@ -691,34 +691,44 @@ static int check_write_permissions (psync_folderid_t folderid) {
691691
psync_sql_free_result(res);
692692
return ret;
693693
}
694-
695-
psync_folderid_t psync_check_and_create_folder (const char * path) {
696-
psync_folderid_t folderid=psync_get_folderid_by_path_or_create(path);
697-
if (folderid==PSYNC_INVALID_FOLDERID || (!check_write_permissions(folderid))){
698-
char *buff=NULL;
699-
uint32_t bufflen;
700-
int ind = 1;
701-
char *err=NULL;
694+
static psync_folderid_t create_index_folder(const char * path) {
695+
char *buff=NULL;
696+
uint32_t bufflen;
697+
int ind = 1;
698+
char * err;
699+
psync_folderid_t folderid;
702700

703-
while (ind < 100) {
704-
folderid=PSYNC_INVALID_FOLDERID;
705-
bufflen = strlen(path) + 1 /*zero char*/ + 3 /*parenthesis*/ + 3 /*up to 3 digit index*/;
706-
buff = (char *) psync_malloc(bufflen);
707-
snprintf(buff, bufflen - 1, "%s (%d)", path, ind);
708-
if (psync_create_remote_folder_by_path(buff, &err)!=0)
709-
debug(D_NOTICE, "Unable to create folder %s error is %s.", buff, err);
710-
folderid=psync_get_folderid_by_path_or_create(buff);
711-
if ((folderid!=PSYNC_INVALID_FOLDERID)&&check_write_permissions(folderid)) {
712-
psync_free(buff);
713-
break;
714-
}
715-
++ind;
716-
717-
if (err)
718-
psync_free(err);
701+
while (ind < 100) {
702+
folderid=PSYNC_INVALID_FOLDERID;
703+
bufflen = strlen(path) + 1 /*zero char*/ + 3 /*parenthesis*/ + 3 /*up to 3 digit index*/;
704+
buff = (char *) psync_malloc(bufflen);
705+
snprintf(buff, bufflen - 1, "%s (%d)", path, ind);
706+
if (psync_create_remote_folder_by_path(buff, &err)!=0)
707+
debug(D_NOTICE, "Unable to create folder %s error is %s.", buff, err);
708+
folderid=psync_get_folderid_by_path(buff);
709+
if ((folderid!=PSYNC_INVALID_FOLDERID)&&check_write_permissions(folderid)) {
719710
psync_free(buff);
711+
break;
720712
}
713+
++ind;
714+
if (err)
715+
psync_free(err);
716+
psync_free(buff);
721717
}
718+
return folderid;
719+
}
720+
psync_folderid_t psync_check_and_create_folder (const char * path) {
721+
psync_folderid_t folderid=psync_get_folderid_by_path(path);
722+
char *err;
723+
724+
if (folderid==PSYNC_INVALID_FOLDERID) {
725+
if(psync_create_remote_folder_by_path(path, &err)!=0) {
726+
debug(D_NOTICE, "Unable to create folder %s error is %s.", path, err);
727+
psync_free(err);
728+
folderid = create_index_folder(path);
729+
}
730+
} else if (!check_write_permissions(folderid))
731+
folderid = create_index_folder(path);
722732

723733
return folderid;
724734
}

pCloudCC/lib/pclsync/pcallbacks.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ static char *fill_formatted_time(char *str, uint64_t totalsec){
172172
return str;
173173
}
174174

175+
static uint64_t sub_no_underf(uint64_t a, uint64_t b){
176+
if (likely(b<a))
177+
return a-b;
178+
else
179+
return 0;
180+
}
181+
175182
static void status_fill_formatted_str(pstatus_t *status, char *downloadstr, char *uploadstr){
176183
char *up, *dw;
177184
uint64_t remsec;
@@ -188,12 +195,12 @@ static void status_fill_formatted_str(pstatus_t *status, char *downloadstr, char
188195
dw=cat_const(dw, "Stopped. ");
189196
else if (status->localisfull)
190197
dw=cat_const(dw, "Disk full. ");
191-
dw=fill_remaining(dw, status->filestodownload, status->bytestodownload-status->bytesdownloaded);
198+
dw=fill_remaining(dw, status->filestodownload, sub_no_underf(status->bytestodownload, status->bytesdownloaded));
192199
}
193200
else{
194201
dw=fill_formatted_bytes(dw, speed);
195202
dw=cat_const(dw, "/sec, ");
196-
dw=fill_remaining(dw, status->filestodownload, status->bytestodownload-status->bytesdownloaded);
203+
dw=fill_remaining(dw, status->filestodownload, sub_no_underf(status->bytestodownload, status->bytesdownloaded));
197204
remsec=(status->bytestodownload-status->bytesdownloaded)/speed;
198205
if (remsec<DONT_SHOW_TIME_IF_SEC_OVER || speed>=DONT_SHOW_TIME_IF_SPEED_BELOW){
199206
*dw++=' ';
@@ -213,12 +220,12 @@ static void status_fill_formatted_str(pstatus_t *status, char *downloadstr, char
213220
up=cat_const(up, "Stopped. ");
214221
else if (status->remoteisfull)
215222
up=cat_const(up, "Account full. ");
216-
up=fill_remaining(up, status->filestoupload, status->bytestoupload-status->bytesuploaded);
223+
up=fill_remaining(up, status->filestoupload, sub_no_underf(status->bytestoupload, status->bytesuploaded));
217224
}
218225
else{
219226
up=fill_formatted_bytes(up, speed);
220227
up=cat_const(up, "/sec, ");
221-
up=fill_remaining(up, status->filestoupload, status->bytestoupload-status->bytesuploaded);
228+
up=fill_remaining(up, status->filestoupload, sub_no_underf(status->bytestoupload, status->bytesuploaded));
222229
remsec=(status->bytestoupload-status->bytesuploaded)/speed;
223230
if (remsec<DONT_SHOW_TIME_IF_SEC_OVER || speed>=DONT_SHOW_TIME_IF_SPEED_BELOW){
224231
*up++=' ';

0 commit comments

Comments
 (0)