@@ -64,8 +64,9 @@ int indexwrite(struct index_s* idx, FILE* s) {
6464 int err = 0 ;
6565 for (long i = 0 ; i < idx -> size ; i ++ ) {
6666 struct inode_s * node = fl [i ];
67- const int n = snprintf (lbuf , sizeof (lbuf ), "%s,%" PRIu64 ",%" PRIu64 "\n" ,
68- node -> fp , node -> st .lmod , node -> st .fsze );
67+ const int n = snprintf (lbuf , sizeof (lbuf ),
68+ "%s,%" PRIu64 ",%" PRIu64 ",%" PRIu64 "\n" , node -> fp ,
69+ node -> st .lmod , node -> st .fsze , node -> xx );
6970 if (fwrite (lbuf , n , 1 , s ) != 1 ) {
7071 err = -1 ;
7172 break ;
@@ -78,10 +79,11 @@ int indexwrite(struct index_s* idx, FILE* s) {
7879int indexread (struct index_s * idx , FILE * s ) {
7980 char fp [INDEXMAXFP ] = {0 }; /* fscanf filepath string buffer */
8081 struct fsstat_s st = {0 }; /* fscanf file stat structure */
81- while (fscanf (s , "%[^,],%" PRIu64 ",%" PRIu64 "\n" , fp , & st .lmod , & st .fsze ) ==
82- 3 ) {
82+ uint64_t xx = 0 ; /* fscanf xxHash64 value */
83+ while (fscanf (s , "%[^,],%" PRIu64 ",%" PRIu64 ",%" PRIu64 "\n" , fp , & st .lmod ,
84+ & st .fsze , & xx ) == 4 ) {
8385 const uint64_t fphash = indexhash (fp );
84- if (indexput (idx , fp , fphash , & st ) == NULL ) return -1 ;
86+ if (indexput (idx , fp , fphash , & st , xx ) == NULL ) return -1 ;
8587 }
8688 return 0 ;
8789}
@@ -101,14 +103,15 @@ static void indexappend(struct ibucket_s* bucket, struct inode_s* node) {
101103}
102104
103105struct inode_s * indexput (struct index_s * idx , const char * fp ,
104- const uint64_t fphash , const struct fsstat_s * st ) {
106+ const uint64_t fphash , const struct fsstat_s * st ,
107+ const uint64_t xx ) {
105108 struct inode_s * node = je_malloc (sizeof (struct inode_s ));
106109 if (node == NULL ) return NULL ;
107110 if ((fp = je_strdup (fp )) == NULL ) {// duplicate filepath string
108111 je_free (node );
109112 return NULL ;
110113 }
111- * node = (struct inode_s ) {(char * ) fp , fphash , * st , NULL };
114+ * node = (struct inode_s ) {(char * ) fp , fphash , * st , xx , NULL };
112115 struct ibucket_s * bucket = & idx -> buckets [indexbucket (node -> fphash )];
113116 indexappend (bucket , node );
114117 idx -> size ++ ;
0 commit comments