From: Fredrik Tolf Date: Thu, 6 Mar 2008 23:58:23 +0000 (+0100) Subject: Count number of shared files. X-Git-Tag: 1.2~6 X-Git-Url: http://dolda2000.com/gitweb/?p=doldaconnect.git;a=commitdiff_plain;h=caa88daef3184efc09e60e9b902d1ae6c98db9fb Count number of shared files. --- diff --git a/daemon/client.c b/daemon/client.c index bf30821..26b50f3 100644 --- a/daemon/client.c +++ b/daemon/client.c @@ -106,6 +106,7 @@ static struct timer *hashwritetimer = NULL; static pid_t hashjob = -1; struct sharecache *shareroot = NULL; static struct timer *scantimer = NULL; +int sharedfiles = 0; unsigned long long sharesize = 0; GCBCHAIN(sharechangecb, unsigned long long); @@ -648,6 +649,8 @@ static void freecache(struct sharecache *node) CBCHAINDOCB(node, share_delete, node); CBCHAINFREE(node, share_delete); sharesize -= node->size; + if(node->f.b.type == FILE_REG) + sharedfiles--; if(node->path != NULL) free(node->path); if(node->name != NULL) @@ -938,6 +941,7 @@ int doscan(int quantum) if(S_ISREG(sb.st_mode)) { sharesize += (n->size = sb.st_size); + sharedfiles++; } else { n->size = 0; } diff --git a/daemon/client.h b/daemon/client.h index 19708d2..0a301ab 100644 --- a/daemon/client.h +++ b/daemon/client.h @@ -93,6 +93,7 @@ int hashcmp(struct hash *h1, struct hash *h2); void scanshares(void); extern struct sharecache *shareroot; +extern int sharedfiles; extern unsigned long long sharesize; EGCBCHAIN(sharechangecb, unsigned long long);