File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,13 @@ def __init__(self) -> None:
8080 def fetch_uri_contents (self , uri : str ) -> bytes :
8181 ipfs_hash = extract_ipfs_path_from_uri (uri )
8282 contents = self .client .cat (ipfs_hash )
83- validation_hash = generate_file_hash (contents )
84- if validation_hash != ipfs_hash :
85- raise EthPMValidationError (
86- f"Hashed IPFS contents retrieved from uri: { uri } do not match its content hash."
83+ # Local validation of hashed contents only works for non-chunked files ~< 256kb
84+ # Improved validation WIP @ https://github.com/ethpm/py-ethpm/pull/165
85+ if len (contents ) <= 262144 :
86+ validation_hash = generate_file_hash (contents )
87+ if validation_hash != ipfs_hash :
88+ raise ValidationError (
89+ f"Hashed IPFS contents retrieved from uri: { uri } do not match its content hash."
8790 )
8891 return contents
8992
You can’t perform that action at this time.
0 commit comments