fix cassette hashing

This commit is contained in:
Ben Burns
2025-02-13 22:56:16 -08:00
parent 2b72fbd5de
commit 2dbdb36743
12 changed files with 269 additions and 29 deletions
+5 -3
View File
@@ -24,14 +24,16 @@ function decompressData(compressedString: string): NockCassetteData {
return msgpack.decode(decompressed) as NockCassetteData;
}
// deno-lint-ignore no-unused-vars
class HashedCassette {
hash: string;
private recording = true;
constructor(
private readonly cassettePath: string,
private readonly hash: string
) {}
hash: string
) {
this.hash = hash;
}
async enter() {
try {
+2 -2
View File
@@ -63,7 +63,7 @@ class HashedCassette:
content = f.read()
try:
cassette_data = serializer.deserialize(content)
except Exception as e:
except Exception:
os.remove(self.cassette_path)
else:
existing_hash = cassette_data.get("cassette_hash")
@@ -96,7 +96,7 @@ class HashedCassette:
content = f.read()
try:
cassette_data = serializer.deserialize(content)
except Exception as e:
except Exception:
return result
# Update the cassette data with the expected hash.
if cassette_data.get("cassette_hash") != self.hash_value: