Skip to content

Commit a6ac7ab

Browse files
Merge branch 'master' of gitlab.pcloud.com:pcloud/synclib
2 parents c8b9149 + d8634bc commit a6ac7ab

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

pcompat.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ typedef unsigned long psync_uint_t;
145145
#define psync_stat_isfolder(s) S_ISDIR((s)->st_mode)
146146
#define psync_stat_size(s) ((s)->st_size)
147147
#ifdef _DARWIN_FEATURE_64_BIT_INODE
148-
#define psync_stat_ctime(s) ((s)->st_birthtime)
148+
#define psync_stat_birthtime(s) ((s)->st_birthtime)
149149
#else
150-
#define psync_stat_ctime(s) ((s)->st_ctime)
150+
#define psync_stat_birthtime(s) ((s)->st_mtime)
151151
#endif
152+
#define psync_stat_ctime(s) ((s)->st_ctime)
152153
#define psync_stat_mtime(s) ((s)->st_mtime)
153154

154155
#if defined(st_mtime)
@@ -266,6 +267,7 @@ int psync_stat(const char *path, psync_stat_t *st);
266267
#define psync_stat_size(s) psync_32to64((s)->nFileSizeHigh, (s)->nFileSizeLow)
267268
#define psync_stat_ctime(s) psync_filetime_to_timet(&(s)->ftCreationTime)
268269
#define psync_stat_mtime(s) psync_filetime_to_timet(&(s)->ftLastWriteTime)
270+
#define psync_stat_birthtime(s) psync_filetime_to_timet(&(s)->ftCreationTime)
269271
#define psync_stat_mtime_native(s) psync_32to64((s)->ftLastWriteTime.dwHighDateTime, (s)->ftLastWriteTime.dwLowDateTime)
270272
#define psync_mtime_native_to_mtime(n) psync_filetime64_to_timet(n)
271273
#define psync_stat_inode(s) psync_32to64((s)->nFileIndexHigh, (s)->nFileIndexLow)

pfs.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ typedef off_t fuse_off_t;
8484

8585
#if defined(P_OS_MACOSX)
8686
#define FS_MAX_ACCEPTABLE_FILENAME_LEN 255
87+
88+
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
89+
#define FUSE_STAT_HAS_BIRTHTIME
90+
#endif
91+
8792
#endif
8893

8994
#if defined(P_OS_LINUX)
@@ -427,7 +432,7 @@ void psync_fs_update_openfile_fileid_locked(psync_openfile_t *of, psync_fsfileid
427432
static void psync_row_to_folder_stat(psync_variant_row row, struct FUSE_STAT *stbuf){
428433
memset(stbuf, 0, sizeof(struct FUSE_STAT));
429434
stbuf->st_ino=folderid_to_inode(psync_get_number(row[0]));
430-
#ifdef _DARWIN_FEATURE_64_BIT_INODE
435+
#ifdef FUSE_STAT_HAS_BIRTHTIME
431436
stbuf->st_birthtime=psync_get_number(row[2]);
432437
stbuf->st_ctime=psync_get_number(row[3]);
433438
stbuf->st_mtime=stbuf->st_ctime;
@@ -454,7 +459,7 @@ static void psync_row_to_file_stat(psync_variant_row row, struct FUSE_STAT *stbu
454459
if (flags&PSYNC_FOLDER_FLAG_ENCRYPTED)
455460
size=psync_fs_crypto_plain_size(size);
456461
memset(stbuf, 0, sizeof(struct FUSE_STAT));
457-
#ifdef _DARWIN_FEATURE_64_BIT_INODE
462+
#ifdef FUSE_STAT_HAS_BIRTHTIME
458463
stbuf->st_birthtime=psync_get_number(row[2]);
459464
stbuf->st_ctime=psync_get_number(row[3]);
460465
stbuf->st_mtime=stbuf->st_ctime;
@@ -480,12 +485,12 @@ static void psync_mkdir_to_folder_stat(psync_fstask_mkdir_t *mk, struct FUSE_STA
480485
stbuf->st_ino=folderid_to_inode(mk->folderid);
481486
else
482487
stbuf->st_ino=taskid_to_inode(-mk->folderid);
483-
#ifdef _DARWIN_FEATURE_64_BIT_INODE
488+
#ifdef FUSE_STAT_HAS_BIRTHTIME
484489
stbuf->st_birthtime=mk->ctime;
485490
stbuf->st_ctime=mk->mtime;
486491
stbuf->st_mtime=mk->mtime;
487492
#else
488-
stbuf->st_ctime=mk->ctime;
493+
stbuf->st_ctime=mk->mtime;
489494
stbuf->st_mtime=mk->mtime;
490495
#endif
491496
stbuf->st_atime=stbuf->st_mtime;
@@ -517,7 +522,7 @@ static int psync_creat_stat_fake_file(struct FUSE_STAT *stbuf){
517522
time_t ctime;
518523
memset(stbuf, 0, sizeof(struct FUSE_STAT));
519524
ctime=psync_timer_time();
520-
#ifdef _DARWIN_FEATURE_64_BIT_INODE
525+
#ifdef FUSE_STAT_HAS_BIRTHTIME
521526
stbuf->st_birthtime=ctime;
522527
#endif
523528
stbuf->st_ctime=ctime;
@@ -611,14 +616,11 @@ static int psync_creat_local_to_file_stat(psync_fstask_creat_t *cr, struct FUSE_
611616
}*/
612617
memset(stbuf, 0, sizeof(struct FUSE_STAT));
613618
stbuf->st_ino=taskid_to_inode(fileid);
614-
#ifdef _DARWIN_FEATURE_64_BIT_INODE
615-
stbuf->st_birthtime=st.st_birthtime;
616-
stbuf->st_ctime=st.st_ctime;
617-
stbuf->st_mtime=st.st_mtime;
618-
#else
619-
stbuf->st_ctime=psync_stat_ctime(&st);
620-
stbuf->st_mtime=psync_stat_mtime(&st);
619+
#ifdef FUSE_STAT_HAS_BIRTHTIME
620+
stbuf->st_birthtime=psync_stat_birthtime(&st);
621621
#endif
622+
stbuf->st_mtime=psync_stat_mtime(&st);
623+
stbuf->st_ctime=stbuf->st_mtime;
622624
stbuf->st_atime=stbuf->st_mtime;
623625
stbuf->st_mode=S_IFREG | 0644;
624626
stbuf->st_nlink=1;
@@ -648,7 +650,7 @@ static int psync_creat_static_to_file_stat(psync_fstask_creat_t *cr, struct FUSE
648650
lc=psync_fstask_creat_get_local(cr);
649651
memset(stbuf, 0, sizeof(struct FUSE_STAT));
650652
stbuf->st_ino=cr->taskid;
651-
#ifdef _DARWIN_FEATURE_64_BIT_INODE
653+
#ifdef FUSE_STAT_HAS_BIRTHTIME
652654
stbuf->st_birthtime=lc->ctime;
653655
stbuf->st_ctime=lc->ctime;
654656
stbuf->st_mtime=lc->ctime;

pfsupload.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,15 +1680,20 @@ static void psync_fsupload_check_tasks(){
16801680
}
16811681

16821682
static void psync_fsupload_thread(){
1683+
int waited;
16831684
clean_stuck_tasks();
1685+
waited=0;
16841686
while (psync_do_run){
16851687
psync_wait_statuses_array(requiredstatusesnooverquota, ARRAY_SIZE(requiredstatusesnooverquota));
16861688
// it is better to sleep a bit to give a chance for events to accumulate
1687-
psync_milisleep(10);
1689+
if (waited)
1690+
psync_milisleep(100);
16881691
psync_fsupload_check_tasks();
16891692
pthread_mutex_lock(&upload_mutex);
1690-
while (!upload_wakes)
1693+
while (!upload_wakes){
16911694
pthread_cond_wait(&upload_cond, &upload_mutex);
1695+
waited=1;
1696+
}
16921697
upload_wakes=0;
16931698
pthread_mutex_unlock(&upload_mutex);
16941699
}

0 commit comments

Comments
 (0)