Skip to content

Commit d815803

Browse files
author
virco
committed
Merge branch 'master' of gitlab.pcloud.com:pcloud/synclib
2 parents 1d95d52 + 11a0f4b commit d815803

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

pdiff.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,9 @@ static void stop_crypto_thread(){
12091209
static void process_modifyuserinfo(const binresult *entry){
12101210
const binresult *res, *cres;
12111211
psync_sql_res *q;
1212-
uint64_t u;
1212+
uint64_t u, crexp, crsub = 0;
1213+
int crst = 0,crstat;
1214+
12131215
if (!entry)
12141216
return;
12151217
res=psync_find_result(entry, "userinfo", PARAM_HASH);
@@ -1247,15 +1249,39 @@ static void process_modifyuserinfo(const binresult *entry){
12471249
psync_sql_run(q);
12481250
if (!u)
12491251
psync_run_thread("stop crypto moduserinfo", stop_crypto_thread);
1252+
else
1253+
crst = 1;
12501254
psync_sql_bind_string(q, 1, "cryptosubscription");
1251-
psync_sql_bind_uint(q, 2, psync_find_result(res, "cryptosubscription", PARAM_BOOL)->num);
1255+
crsub = psync_find_result(res, "cryptosubscription", PARAM_BOOL)->num;
1256+
psync_sql_bind_uint(q, 2, crsub);
12521257
psync_sql_run(q);
12531258
cres=psync_check_result(res, "cryptoexpires", PARAM_NUM);
1259+
crexp = cres?cres->num:0;
12541260
psync_sql_bind_string(q, 1, "cryptoexpires");
1255-
psync_sql_bind_uint(q, 2, cres?cres->num:0);
1261+
psync_sql_bind_uint(q, 2, crexp);
1262+
psync_sql_run(q);
1263+
if (psync_is_business || crsub){
1264+
if (crst)
1265+
crstat = 5;
1266+
else crstat = 4;
1267+
} else {
1268+
if (!crst)
1269+
crstat = 1;
1270+
else
1271+
{
1272+
if (psync_millitime() > crexp)
1273+
crstat = 3;
1274+
else
1275+
crstat = 2;
1276+
}
1277+
}
1278+
psync_sql_bind_string(q, 1, "cryptostatus");
1279+
psync_sql_bind_uint(q, 2, crstat);
12561280
psync_sql_run(q);
12571281
psync_sql_free_result(q);
12581282
psync_send_eventid(PEVENT_USERINFO_CHANGED);
1283+
1284+
12591285
}
12601286

12611287
#define fill_str(f, s, sl)\

poverlay.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ static int get_item_from_cache(const char* key, external_status* stat){
7979
now = psync_millitime();
8080
if ((now - rec->timestamp) < 100) {
8181
*stat = rec->stat;
82+
psync_cache_add(reckey, rec, 1, psync_free, 1);
83+
psync_free(reckey);
8284
return 1;
8385
} else {
8486
psync_free(rec);
8587
}
8688
}
89+
psync_free(reckey);
8790
return 0;
8891
}
8992
@@ -97,7 +100,8 @@ static void add_item_to_cache(const char* key, external_status* stat){
97100
98101
rec->stat = *stat;
99102
rec->timestamp = psync_millitime();
100-
psync_cache_add(key, rec, 1, psync_free, 1);
103+
psync_cache_add(reckey, rec, 1, psync_free, 1);
104+
psync_free(reckey);
101105
}
102106
103107
*/

psynclib.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ typedef struct pstatus_struct_ {
262262
#define PSYNC_CRYPTO_FOLDER_NOT_ENCRYPTED -7
263263
#define PSYNC_CRYPTO_INTERNAL_ERROR -8
264264

265+
#define PSYNC_CRYPTO_STATUS_NEW 1
266+
#define PSYNC_CRYPTO_STATUS_TRIAL 2
267+
#define PSYNC_CRYPTO_STATUS_EXPIRED 3
268+
#define PSYNC_CRYPTO_STATUS_ACTIVE 4
269+
#define PSYNC_CRYPTO_STATUS_SETUP 5
270+
265271
#define PSYNC_CRYPTO_INVALID_FOLDERID ((psync_folderid_t)-1)
266272

267273
#ifndef DEFAULT_FUSE_VOLUME_NAME
@@ -1148,7 +1154,6 @@ void psync_start_overlay_callbacks();
11481154

11491155
int psync_setlanguage(const char *language, char **err);
11501156

1151-
11521157
#ifdef __cplusplus
11531158
}
11541159
#endif

0 commit comments

Comments
 (0)