Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/rift/Annex.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,22 @@ def is_pointer(cls, filepath):
Return true if content of file at filepath looks like a valid digest
identifier.
"""
with open(filepath, encoding='utf-8') as fh:
identifier = fh.read()
# Remove possible trailing whitespace, newline and carriage return
# characters.
identifier = identifier.rstrip()
try:
with open(filepath, encoding='utf-8') as fh:
identifier = fh.read()
# Remove possible trailing whitespace, newline and carriage return
# characters.
identifier = identifier.rstrip()

except UnicodeDecodeError:
# Binary fileis cannot be decoded with UTF-8
return False

# Check size corresponds to MD5 (32) or SHA3 256 (64).
if len(identifier) in (32, 64):
return all(byte in string.hexdigits for byte in identifier)

# If the identifier is not a valid Rift Annex pointer
return False

def make_restore_cache(self):
Expand Down