@@ -323,17 +323,9 @@ sentry__process_old_runs(const sentry_options_t *options, uint64_t last_crash)
323323typedef struct {
324324 sentry_path_t * path ;
325325 time_t mtime ;
326- size_t size_in_kb ;
326+ size_t size ;
327327} cache_entry_t ;
328328
329- static size_t
330- get_file_size_in_kb (const sentry_path_t * path )
331- {
332- size_t bytes = sentry__path_get_size (path );
333- // Round up to next KB boundary
334- return (bytes + 1023 ) / 1024 ;
335- }
336-
337329/**
338330 * Comparison function to sort cache entries by mtime, newest first.
339331 */
@@ -398,7 +390,7 @@ sentry__cleanup_cache(const sentry_options_t *options)
398390
399391 entries [entries_count ].path = sentry__path_clone (entry );
400392 entries [entries_count ].mtime = sentry__path_get_mtime (entry );
401- entries [entries_count ].size_in_kb = get_file_size_in_kb (entry );
393+ entries [entries_count ].size = sentry__path_get_size (entry );
402394 entries_count ++ ;
403395 }
404396 sentry__pathiter_free (iter );
@@ -414,7 +406,7 @@ sentry__cleanup_cache(const sentry_options_t *options)
414406
415407 // Prune entries: iterate newest-to-oldest, accumulating size
416408 // Remove if: too old OR accumulated size exceeds limit
417- size_t accumulated_size_kb = 0 ;
409+ size_t accumulated_size = 0 ;
418410 for (size_t i = 0 ; i < entries_count ; i ++ ) {
419411 bool should_prune = false;
420412
@@ -424,9 +416,9 @@ sentry__cleanup_cache(const sentry_options_t *options)
424416 }
425417
426418 // Size-based pruning (accumulate size as we go, like crashpad)
427- accumulated_size_kb += entries [i ].size_in_kb ;
419+ accumulated_size += entries [i ].size ;
428420 if (options -> cache_max_size > 0
429- && accumulated_size_kb > ( size_t ) options -> cache_max_size ) {
421+ && accumulated_size > options -> cache_max_size ) {
430422 should_prune = true;
431423 }
432424
0 commit comments