Changeset 5357

Show
Ignore:
Timestamp:
03/12/08 05:29:55 (4 months ago)
Author:
morris
Message:

Count files and directories via inode per device to avoid possible false duplicates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wired/trunk/wired/files.c

    r5355 r5357  
    8787static wi_lock_t                                                        *wd_files_indexer_lock; 
    8888static wi_uinteger_t                                            wd_files_index_level; 
    89 static wi_set_t                                                                *wd_files_index_set
     89static wi_hash_t                                                       *wd_files_index_hash
    9090 
    9191wi_uinteger_t                                                           wd_files_count, wd_files_unique_count; 
     
    826826        wi_string_t                     *path, *realpath; 
    827827        wi_time_interval_t      interval; 
    828         wi_uinteger_t           count, capacity; 
    829828         
    830829        pool = wi_pool_init(wi_pool_alloc()); 
     
    834833 
    835834                interval = wi_time_interval(); 
    836                 count = wd_files_unique_count + wd_directories_unique_count; 
    837  
    838                 if(count > 100) 
    839                         capacity = 100 + (count / 100.0f); 
    840                 else if(count > 0) 
    841                         capacity = count; 
    842                 else 
    843                         capacity = 100; 
    844835 
    845836                wd_files_count = wd_files_unique_count = 0; 
    846837                wd_directories_count = wd_directories_unique_count = 0; 
    847838                wd_files_size = wd_files_unique_size = 0; 
    848                  
    849                 wd_files_index_level    = 0; 
    850                 wd_files_index_set              = wi_autorelease(wi_set_init_with_capacity(wi_set_alloc(), capacity)); 
     839                wd_files_index_level = 0; 
     840                 
     841                wd_files_index_hash = wi_autorelease(wi_hash_init_with_capacity_and_callbacks(wi_hash_alloc(), 0, 
     842                        wi_hash_null_key_callbacks, wi_hash_default_value_callbacks)); 
    851843 
    852844                path = wi_string_with_format(WI_STR("%@~"), wd_settings.index); 
     
    910902        WI_FTSENT                               *p; 
    911903        wi_string_t                             *filepath, *virtualpath, *string; 
     904        wi_set_t                                *set; 
    912905        wi_number_t                             *number; 
    913906        wi_file_offset_t                size; 
     
    10191012 
    10201013                /* track unique inodes */ 
     1014                set = wi_hash_data_for_key(wd_files_index_hash, (void *) sb.dev); 
     1015                 
     1016                if(!set) { 
     1017                        set = wi_set_init_with_capacity(wi_set_alloc(), 1000); 
     1018                        wi_hash_set_data_for_key(wd_files_index_hash, set, (void *) sb.dev); 
     1019                        wi_release(set); 
     1020                } 
     1021                 
    10211022                number = wi_number_with_value(WI_NUMBER_INT64, &sb.ino); 
    10221023                 
    1023                 if(!wi_set_contains_data(wd_files_index_set, number)) { 
     1024                if(!wi_set_contains_data(set, number)) { 
    10241025                        if(S_ISDIR(sb.mode)) { 
    10251026                                wd_directories_unique_count++; 
     
    10291030                        } 
    10301031 
    1031                         wi_set_add_data(wd_files_index_set, number); 
     1032                        wi_set_add_data(set, number); 
    10321033                } 
    10331034