Fossil

Check-in [c47adb91]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Calculate hash lengths with skipped directory slashes.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | reconstruct-sha3
Files: files | file ages | folders
SHA3-256: c47adb9148576228c297b2c134cd0b5408eb2e1be1dce565a9a5c0be4975dd70
User & Date: florian 2019-01-29 14:09:00.000
Context
2019-01-29
14:29
Add a test command to infer the hash policy from the length of path names on reconstruct (disabled by preprocessor directive). ... (Closed-Leaf check-in: 8d1ed47c user: florian tags: reconstruct-sha3)
14:09
Calculate hash lengths with skipped directory slashes. ... (check-in: c47adb91 user: florian tags: reconstruct-sha3)
14:01
Coding style fixes. ... (check-in: 1d49b5ad user: florian tags: reconstruct-sha3)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/rebuild.c.
1042
1043
1044
1045
1046
1047
1048


1049
1050
1051
1052
1053
1054
1055

1056

1057
1058
1059
1060
1061
1062
1063
*/
static int saved_eHashPolicy = -1;

void recon_set_hash_policy(
  const int cchPathPrefix,    /* Directory prefix length for zUuidAsFilePath */
  const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
){


  int cchTotal, cchHashPart;
  int new_eHashPolicy = -1;
  assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
  if( zUuidAsFilePath==0 ) return;
  cchTotal = strlen(zUuidAsFilePath);
  if( cchTotal==0 ) return;
  if( cchPathPrefix>=cchTotal ) return;

  cchHashPart = cchTotal - cchPathPrefix;

  if( cchHashPart>=HNAME_LEN_K256 ){
    new_eHashPolicy = HPOLICY_SHA3;
  }else if( cchHashPart>=HNAME_LEN_SHA1 ){
    new_eHashPolicy = HPOLICY_SHA1;
  }
  if( new_eHashPolicy!=-1 ){
    saved_eHashPolicy = g.eHashPolicy;







>
>
|



|
|
|
>
|
>







1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
*/
static int saved_eHashPolicy = -1;

void recon_set_hash_policy(
  const int cchPathPrefix,    /* Directory prefix length for zUuidAsFilePath */
  const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
){
  int cchUuidAsFilePath;
  const char *zHashPart;
  int cchHashPart = 0;
  int new_eHashPolicy = -1;
  assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
  if( zUuidAsFilePath==0 ) return;
  cchUuidAsFilePath = strlen(zUuidAsFilePath);
  if( cchUuidAsFilePath==0 ) return;
  if( cchPathPrefix>=cchUuidAsFilePath ) return;
  for( zHashPart = zUuidAsFilePath + cchPathPrefix; *zHashPart; zHashPart++ ){
    if( *zHashPart!='/' ) cchHashPart++;
  }
  if( cchHashPart>=HNAME_LEN_K256 ){
    new_eHashPolicy = HPOLICY_SHA3;
  }else if( cchHashPart>=HNAME_LEN_SHA1 ){
    new_eHashPolicy = HPOLICY_SHA1;
  }
  if( new_eHashPolicy!=-1 ){
    saved_eHashPolicy = g.eHashPolicy;