Fossil SCM
Calculate hash lengths with skipped directory slashes.
Commit
c47adb9148576228c297b2c134cd0b5408eb2e1be1dce565a9a5c0be4975dd70
Parent
1d49b5ad9118d0a…
1 file changed
+9
-5
+9
-5
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -1044,18 +1044,22 @@ | ||
| 1044 | 1044 | |
| 1045 | 1045 | void recon_set_hash_policy( |
| 1046 | 1046 | const int cchPathPrefix, /* Directory prefix length for zUuidAsFilePath */ |
| 1047 | 1047 | const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */ |
| 1048 | 1048 | ){ |
| 1049 | - int cchTotal, cchHashPart; | |
| 1049 | + int cchUuidAsFilePath; | |
| 1050 | + const char *zHashPart; | |
| 1051 | + int cchHashPart = 0; | |
| 1050 | 1052 | int new_eHashPolicy = -1; |
| 1051 | 1053 | assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */ |
| 1052 | 1054 | if( zUuidAsFilePath==0 ) return; |
| 1053 | - cchTotal = strlen(zUuidAsFilePath); | |
| 1054 | - if( cchTotal==0 ) return; | |
| 1055 | - if( cchPathPrefix>=cchTotal ) return; | |
| 1056 | - cchHashPart = cchTotal - cchPathPrefix; | |
| 1055 | + cchUuidAsFilePath = strlen(zUuidAsFilePath); | |
| 1056 | + if( cchUuidAsFilePath==0 ) return; | |
| 1057 | + if( cchPathPrefix>=cchUuidAsFilePath ) return; | |
| 1058 | + for( zHashPart = zUuidAsFilePath + cchPathPrefix; *zHashPart; zHashPart++ ){ | |
| 1059 | + if( *zHashPart!='/' ) cchHashPart++; | |
| 1060 | + } | |
| 1057 | 1061 | if( cchHashPart>=HNAME_LEN_K256 ){ |
| 1058 | 1062 | new_eHashPolicy = HPOLICY_SHA3; |
| 1059 | 1063 | }else if( cchHashPart>=HNAME_LEN_SHA1 ){ |
| 1060 | 1064 | new_eHashPolicy = HPOLICY_SHA1; |
| 1061 | 1065 | } |
| 1062 | 1066 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -1044,18 +1044,22 @@ | |
| 1044 | |
| 1045 | void recon_set_hash_policy( |
| 1046 | const int cchPathPrefix, /* Directory prefix length for zUuidAsFilePath */ |
| 1047 | const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */ |
| 1048 | ){ |
| 1049 | int cchTotal, cchHashPart; |
| 1050 | int new_eHashPolicy = -1; |
| 1051 | assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */ |
| 1052 | if( zUuidAsFilePath==0 ) return; |
| 1053 | cchTotal = strlen(zUuidAsFilePath); |
| 1054 | if( cchTotal==0 ) return; |
| 1055 | if( cchPathPrefix>=cchTotal ) return; |
| 1056 | cchHashPart = cchTotal - cchPathPrefix; |
| 1057 | if( cchHashPart>=HNAME_LEN_K256 ){ |
| 1058 | new_eHashPolicy = HPOLICY_SHA3; |
| 1059 | }else if( cchHashPart>=HNAME_LEN_SHA1 ){ |
| 1060 | new_eHashPolicy = HPOLICY_SHA1; |
| 1061 | } |
| 1062 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -1044,18 +1044,22 @@ | |
| 1044 | |
| 1045 | void recon_set_hash_policy( |
| 1046 | const int cchPathPrefix, /* Directory prefix length for zUuidAsFilePath */ |
| 1047 | const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */ |
| 1048 | ){ |
| 1049 | int cchUuidAsFilePath; |
| 1050 | const char *zHashPart; |
| 1051 | int cchHashPart = 0; |
| 1052 | int new_eHashPolicy = -1; |
| 1053 | assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */ |
| 1054 | if( zUuidAsFilePath==0 ) return; |
| 1055 | cchUuidAsFilePath = strlen(zUuidAsFilePath); |
| 1056 | if( cchUuidAsFilePath==0 ) return; |
| 1057 | if( cchPathPrefix>=cchUuidAsFilePath ) return; |
| 1058 | for( zHashPart = zUuidAsFilePath + cchPathPrefix; *zHashPart; zHashPart++ ){ |
| 1059 | if( *zHashPart!='/' ) cchHashPart++; |
| 1060 | } |
| 1061 | if( cchHashPart>=HNAME_LEN_K256 ){ |
| 1062 | new_eHashPolicy = HPOLICY_SHA3; |
| 1063 | }else if( cchHashPart>=HNAME_LEN_SHA1 ){ |
| 1064 | new_eHashPolicy = HPOLICY_SHA1; |
| 1065 | } |
| 1066 |