-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Checksum handling is now part of the virtual filestore abstraction 2. CRC algorithm is now used for empty files as well instead of hardcoding the checksum type to the NULL checksum for these cases
- Loading branch information
Showing
12 changed files
with
207 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import struct | ||
from pathlib import Path | ||
|
||
|
||
def calc_modular_checksum(file_path: Path) -> bytes: | ||
"""Calculates the modular checksum for a file in one go.""" | ||
checksum = 0 | ||
|
||
with open(file_path, "rb") as file: | ||
while True: | ||
data = file.read(4) | ||
if not data: | ||
break | ||
checksum += int.from_bytes( | ||
data.ljust(4, b"\0"), byteorder="big", signed=False | ||
) | ||
|
||
checksum %= 2**32 | ||
return struct.pack("!I", checksum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.