Skip to content

Commit 4acfe62

Browse files
author
virco
committed
Merge branch 'master' of gitlab.pcloud.com:pcloud/synclib
2 parents cf8fd99 + 1a4c5cd commit 4acfe62

File tree

6 files changed

+27
-21
lines changed

6 files changed

+27
-21
lines changed

pcompat.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -617,22 +617,22 @@ static void psync_get_random_seed_from_db(psync_lhash_ctx *hctx){
617617
psync_lhash_update(hctx, &tm, sizeof(&tm));
618618
res=psync_sql_query_rdlock("SELECT * FROM setting ORDER BY RANDOM()");
619619
psync_get_random_seed_from_query(hctx, res);
620-
res=psync_sql_query_rdlock("SELECT * FROM filerevision ORDER BY RANDOM() LIMIT 50");
620+
res=psync_sql_query_rdlock("SELECT * FROM resolver ORDER BY RANDOM() LIMIT 50");
621+
psync_get_random_seed_from_query(hctx, res);
622+
/* res=psync_sql_query_rdlock("SELECT * FROM filerevision ORDER BY RANDOM() LIMIT 50");
621623
psync_get_random_seed_from_query(hctx, res);
622624
res=psync_sql_query_rdlock("SELECT * FROM file ORDER BY RANDOM() LIMIT 50");
623625
psync_get_random_seed_from_query(hctx, res);
624626
res=psync_sql_query_rdlock("SELECT * FROM localfile ORDER BY RANDOM() LIMIT 50");
625627
psync_get_random_seed_from_query(hctx, res);
626-
res=psync_sql_query_rdlock("SELECT * FROM resolver ORDER BY RANDOM() LIMIT 50");
627-
psync_get_random_seed_from_query(hctx, res);
628628
res=psync_sql_query_rdlock("SELECT * FROM folder ORDER BY RANDOM() LIMIT 25");
629629
psync_get_random_seed_from_query(hctx, res);
630630
res=psync_sql_query_rdlock("SELECT * FROM localfolder ORDER BY RANDOM() LIMIT 25");
631631
psync_get_random_seed_from_query(hctx, res);
632632
res=psync_sql_query_rdlock("SELECT * FROM hashchecksum ORDER BY RANDOM() LIMIT 25");
633633
psync_get_random_seed_from_query(hctx, res);
634634
res=psync_sql_query_rdlock("SELECT * FROM pagecache WHERE type=1 AND rowid>(ABS(RANDOM())%(SELECT MAX(rowid)+1 FROM pagecache)) ORDER BY rowid LIMIT 50");
635-
psync_get_random_seed_from_query(hctx, res);
635+
psync_get_random_seed_from_query(hctx, res); */
636636
psync_sql_statement("REPLACE INTO setting (id, value) VALUES ('random', RANDOM())");
637637
psync_nanotime(&tm);
638638
psync_lhash_update(hctx, &tm, sizeof(&tm));
@@ -665,12 +665,12 @@ static void psync_store_seed_in_db(const unsigned char *seed){
665665
unsigned char hashbin[PSYNC_LHASH_DIGEST_LEN];
666666
char hashhex[PSYNC_LHASH_DIGEST_HEXLEN], nm[16];
667667
memcpy(hashbin, seed, PSYNC_LHASH_DIGEST_LEN);
668-
psync_rehash_cnt(hashbin, 5000);
668+
psync_rehash_cnt(hashbin, 2000);
669669
psync_binhex(hashhex, hashbin, PSYNC_LHASH_DIGEST_LEN);
670670
res=psync_sql_prep_statement("REPLACE INTO setting (id, value) VALUES ('randomhash', ?)");
671671
psync_sql_bind_lstring(res, 1, hashhex, PSYNC_LHASH_DIGEST_HEXLEN);
672672
psync_sql_run_free(res);
673-
psync_rehash_cnt(hashbin, 5000);
673+
psync_rehash_cnt(hashbin, 2000);
674674
psync_binhex(hashhex, hashbin, PSYNC_LHASH_DIGEST_LEN);
675675
memcpy(nm, "randomhash", 10);
676676
nm[10]=hashhex[0];
@@ -691,7 +691,7 @@ void psync_get_random_seed(unsigned char *seed, const void *addent, size_t aelen
691691
psync_uint_t i, j;
692692
int64_t i64;
693693
pthread_t threadid;
694-
unsigned char lsc[100][PSYNC_LHASH_DIGEST_LEN];
694+
unsigned char lsc[64][PSYNC_LHASH_DIGEST_LEN];
695695
#if defined(P_OS_POSIX)
696696
debug(D_NOTICE, "in");
697697
struct utsname un;
@@ -802,7 +802,6 @@ void psync_get_random_seed(unsigned char *seed, const void *addent, size_t aelen
802802
if (home){
803803
i64=psync_get_free_space_by_path(home);
804804
psync_lhash_update(&hctx, &i64, sizeof(i64));
805-
psync_lhash_update(&hctx, &home, sizeof(home));
806805
psync_lhash_update(&hctx, home, strlen(home));
807806
if (likely_log(!psync_stat(home, &st)))
808807
psync_lhash_update(&hctx, &st, sizeof(st));
@@ -821,7 +820,7 @@ void psync_get_random_seed(unsigned char *seed, const void *addent, size_t aelen
821820
for (j=0; j<PSYNC_LHASH_DIGEST_LEN; j++)
822821
lsc[i][j]^=(unsigned char)i;
823822
}
824-
for (j=fast?98:0; j<100; j++){
823+
for (j=fast?3:0; j<5; j++){
825824
for (i=0; i<100; i++){
826825
psync_lhash_update(&hctx, &i, sizeof(i));
827826
psync_lhash_update(&hctx, &j, sizeof(j));

pfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,7 @@ PSYNC_NOINLINE static int psync_fs_do_check_write_space(psync_openfile_t *of, si
21662166
debug(D_WARNING, "could not get free space of path %s", cachepath);
21672167
return 1;
21682168
}
2169+
// debug(D_NOTICE, "free space of %s is %lld minlocal %llu", cachepath, freespc, minlocal);
21692170
if (freespc>=minlocal+size){
21702171
psync_set_local_full(0);
21712172
of->throttle=0;
@@ -2221,11 +2222,11 @@ PSYNC_NOINLINE static int psync_fs_do_check_write_space(psync_openfile_t *of, si
22212222
}
22222223

22232224
static int psync_fs_check_write_space(psync_openfile_t *of, size_t size, fuse_off_t offset){
2224-
if (!of->throttle && of->writeid%256==0)
2225+
if (!of->throttle && of->writeid%64!=0)
22252226
return 1;
22262227
if (of->currentsize>=offset+size){
2227-
if (of->newfile)
2228-
return 1;
2228+
// if (of->newfile)
2229+
// return 1;
22292230
if (of->modified && psync_fs_check_modified_file_write_space(of, size, offset))
22302231
return 1;
22312232
}

pfstasks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,8 @@ int psync_fstask_unlink(psync_fsfolderid_t folderid, const char *name){
864864
psync_tree_del(&folder->creats, &cr->tree);
865865
psync_free(cr);
866866
folder->taskscnt--;
867+
if (folder->folderid>=0)
868+
psync_path_status_drive_folder_changed(folder->folderid);
867869
}
868870
revoffileid=get_file_at_old_location(fileid);
869871
psync_sql_start_transaction();
@@ -977,6 +979,8 @@ int psync_fstask_rename_file(psync_fsfileid_t fileid, psync_fsfolderid_t parentf
977979
psync_tree_del(&folder->creats, &cr->tree);
978980
psync_free(cr);
979981
folder->taskscnt--;
982+
if (folder->folderid>=0)
983+
psync_path_status_drive_folder_changed(folder->folderid);
980984
}
981985
psync_fs_rename_openfile_locked(fileid, to_folderid, new_name);
982986
nlen++;

ppagecache.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,11 +3312,12 @@ void psync_pagecache_init(){
33123312
}
33133313
db_cache_in_pages=psync_setting_get_uint(_PS(fscachesize))/PSYNC_FS_PAGE_SIZE;
33143314
db_cache_max_page=psync_sql_cellint("SELECT MAX(id) FROM pagecache", 0);
3315-
if (db_cache_max_page<db_cache_in_pages){
3315+
free_db_pages=psync_sql_cellint("SELECT COUNT(*) FROM pagecache WHERE type="NTO_STR(PAGE_TYPE_FREE), 0);
3316+
if (db_cache_max_page<db_cache_in_pages && free_db_pages<CACHE_PAGES*2){
33163317
i=0;
33173318
psync_sql_start_transaction();
33183319
res=psync_sql_prep_statement("INSERT INTO pagecache (type) VALUES ("NTO_STR(PAGE_TYPE_FREE)")");
3319-
while (db_cache_max_page+i<db_cache_in_pages && i<CACHE_PAGES*4){
3320+
while (db_cache_max_page+i<db_cache_in_pages && i<CACHE_PAGES*2){
33203321
psync_sql_run(res);
33213322
i++;
33223323
}
@@ -3329,9 +3330,10 @@ void psync_pagecache_init(){
33293330
}
33303331
readcache=psync_file_open(cache_file, P_O_RDWR, P_O_CREAT);
33313332
psync_free(cache_file);
3333+
if (likely_log(psync_file_seek(readcache, db_cache_max_page*PSYNC_FS_PAGE_SIZE, P_SEEK_SET)!=-1))
3334+
assertw(psync_file_truncate(readcache)==0);
33323335
if (db_cache_max_page>db_cache_in_pages)
33333336
psync_pagecache_resize_cache();
3334-
free_db_pages=psync_sql_cellint("SELECT COUNT(*) FROM pagecache WHERE type="NTO_STR(PAGE_TYPE_FREE), 0);
33353337
pthread_mutex_lock(&flush_cache_mutex);
33363338
check_disk_full();
33373339
pthread_mutex_unlock(&flush_cache_mutex);

psynclib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,8 +1575,8 @@ int psync_upload_data(psync_folderid_t folderid, const char *remote_filename, co
15751575
return psync_upload_params(params, ARRAY_SIZE(params), data, length, fileid);
15761576
}
15771577

1578-
int psync_upload_data_as(const char *remote_path, const void *data, size_t length, psync_fileid_t *fileid){
1579-
binparam params[]={P_STR("auth", psync_my_auth), P_STR("path", remote_path), P_BOOL("nopartial", 1)};
1578+
int psync_upload_data_as(const char *remote_path, const char *remote_filename, const void *data, size_t length, psync_fileid_t *fileid){
1579+
binparam params[]={P_STR("auth", psync_my_auth), P_STR("path", remote_path), P_STR("filename", remote_filename), P_BOOL("nopartial", 1)};
15801580
return psync_upload_params(params, ARRAY_SIZE(params), data, length, fileid);
15811581
}
15821582

@@ -1630,13 +1630,13 @@ int psync_upload_file(psync_folderid_t folderid, const char *remote_filename, co
16301630
return ret;
16311631
}
16321632

1633-
int psync_upload_file_as(const char *remote_path, const char *local_path, psync_fileid_t *fileid){
1633+
int psync_upload_file_as(const char *remote_path, const char *remote_filename, const char *local_path, psync_fileid_t *fileid){
16341634
char *data;
16351635
size_t length;
16361636
int ret;
16371637
if (psync_load_file(local_path, &data, &length))
16381638
return -2;
1639-
ret=psync_upload_data_as(remote_path, data, length, fileid);
1639+
ret=psync_upload_data_as(remote_path, remote_filename, data, length, fileid);
16401640
psync_free(data);
16411641
return ret;
16421642
}

psynclib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,9 @@ void psync_run_new_version(psync_new_version_t *ver);
934934
*/
935935

936936
int psync_upload_data(psync_folderid_t folderid, const char *remote_filename, const void *data, size_t length, psync_fileid_t *fileid);
937-
int psync_upload_data_as(const char *remote_path, const void *data, size_t length, psync_fileid_t *fileid);
937+
int psync_upload_data_as(const char *remote_path, const char *remote_filename, const void *data, size_t length, psync_fileid_t *fileid);
938938
int psync_upload_file(psync_folderid_t folderid, const char *remote_filename, const char *local_path, psync_fileid_t *fileid);
939-
int psync_upload_file_as(const char *remote_path, const char *local_path, psync_fileid_t *fileid);
939+
int psync_upload_file_as(const char *remote_path, const char *remote_filename, const char *local_path, psync_fileid_t *fileid);
940940

941941
/* Filesystem functions.
942942
*

0 commit comments

Comments
 (0)