File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -331,18 +331,33 @@ fossil_io_archive_t* fossil_io_archive_create(const char *path, fossil_io_archiv
331331bool fossil_io_archive_get_stats (fossil_io_archive_t * archive , fossil_io_archive_stats_t * stats ) {
332332 if (!archive || !stats ) return false;
333333
334- stats -> total_entries = archive -> entry_count ;
334+ stats -> total_entries = 0 ;
335335 stats -> total_size = 0 ;
336336 stats -> compressed_size = 0 ;
337-
337+
338338 for (size_t i = 0 ; i < archive -> entry_count ; i ++ ) {
339- stats -> total_size += archive -> entries [i ].size ;
340- stats -> compressed_size += archive -> entries [i ].compressed_size ;
339+ const fossil_io_archive_entry_t * entry = & archive -> entries [i ];
340+ bool duplicate = false;
341+
342+ // Check if we've seen this entry name before
343+ for (size_t j = 0 ; j < i ; j ++ ) {
344+ if (strcmp (archive -> entries [j ].name , entry -> name ) == 0 ) {
345+ duplicate = true;
346+ break ;
347+ }
348+ }
349+
350+ if (duplicate ) continue ;
351+
352+ stats -> total_entries ++ ;
353+ stats -> total_size += entry -> size ;
354+ stats -> compressed_size += entry -> compressed_size ;
341355 }
342-
343- stats -> compression_ratio = stats -> total_size > 0 ?
356+
357+ stats -> compression_ratio =
358+ stats -> total_size > 0 ?
344359 (double )stats -> compressed_size / stats -> total_size : 0.0 ;
345-
360+
346361 return true;
347362}
348363
You can’t perform that action at this time.
0 commit comments