zimeon / ocfl-py

OCFL tools in Python
MIT License
20 stars 7 forks source link

Handle case of file specified in fixity that is missing #47

Closed zimeon closed 3 years ago

zimeon commented 3 years ago

Current code fails on https://github.com/OCFL/fixtures/pull/68

ocfl-validate.py 1.0/bad-objects/E092_E093_content_path_does_not_exist
Traceback (most recent call last):
  File "/Users/simeon/.python_venv/py38/lib/python3.8/site-packages/fs/osfs.py", line 359, in openbin
    binary_file = io.open(
FileNotFoundError: [Errno 2] No such file or directory: b'/Users/simeon/src/ocfl-py/fixtures/1.0/bad-objects/E092_E093_content_path_does_not_exist/v1/content/bonus.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../ocfl-validate.py", line 46, in <module>
    if obj.validate(path,
  File "/Users/simeon/src/ocfl-py/ocfl/object.py", line 525, in validate
    passed = validator.validate(objdir)
  File "/Users/simeon/src/ocfl-py/ocfl/validator.py", line 108, in validate
    self.validate_content(inventory, all_versions, prior_manifest_digests)
  File "/Users/simeon/src/ocfl-py/ocfl/validator.py", line 306, in validate_content
    content_digest = file_digest(filepath, digest_type=digest_algorithm, pyfs=self.obj_fs)
  File "/Users/simeon/src/ocfl-py/ocfl/digest.py", line 51, in file_digest
    return _file_digest(pyfs, filename, hashlib.md5())
  File "/Users/simeon/src/ocfl-py/ocfl/digest.py", line 27, in _file_digest
    _fs_digest(pyfs, filename, digester)
  File "/Users/simeon/src/ocfl-py/ocfl/digest.py", line 11, in _fs_digest
    with pyfs.openbin(filename, 'r') as fh:
  File "/Users/simeon/.python_venv/py38/lib/python3.8/site-packages/fs/osfs.py", line 359, in openbin
    binary_file = io.open(
  File "/Users/simeon/.python_venv/py38/lib/python3.8/site-packages/fs/error_tools.py", line 90, in __exit__
    reraise(fserror, fserror(self._path, exc=exc_value), traceback)
  File "/Users/simeon/.python_venv/py38/lib/python3.8/site-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/Users/simeon/.python_venv/py38/lib/python3.8/site-packages/fs/osfs.py", line 359, in openbin
    binary_file = io.open(
fs.errors.ResourceNotFound: resource 'v1/content/bonus.txt' not found
zimeon commented 3 years ago

Fixed in 1.2.2