RhetTbull / osxmetadata

Python package to read and write various MacOS extended attribute metadata such as tags/keywords and Finder comments from files. Includes CLI tool for reading/writing metadata.
MIT License
127 stars 3 forks source link

TypeError: '__NSTaggedDate' object is not iterable during backup #74

Closed RhetTbull closed 2 years ago

RhetTbull commented 2 years ago
python -m osxmetadata --backup *
Traceback (most recent call last):
  File "/Users/rhet/.pyenv/versions/3.10.5/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/rhet/.pyenv/versions/3.10.5/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/__main__.py", line 1128, in <module>
    cli()  # pylint: disable=no-value-for-parameter
  File "/Users/rhet/.pyenv/versions/3.10.5/envs/osxmetadata/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/rhet/.pyenv/versions/3.10.5/envs/osxmetadata/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/rhet/.pyenv/versions/3.10.5/envs/osxmetadata/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/rhet/.pyenv/versions/3.10.5/envs/osxmetadata/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/rhet/.pyenv/versions/3.10.5/envs/osxmetadata/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/__main__.py", line 954, in cli
    process_files(
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/__main__.py", line 1062, in process_files
    md_backup_metadata(fpath, backup_file, verbose)
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/__main__.py", line 595, in md_backup_metadata
    backup_dict = get_backup_dict(filepath)
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/backup.py", line 22, in get_backup_dict
    backup_dict = md.asdict()
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/osxmetadata.py", line 157, in asdict
    return {key: getattr(self, key) for key in attributes}
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/osxmetadata.py", line 157, in <dictcomp>
    return {key: getattr(self, key) for key in attributes}
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/osxmetadata.py", line 221, in __getattr__
    return get_mditem_metadata(self._mditem, attribute)
  File "/Users/rhet/Dropbox/Code/osxmetadata/osxmetadata/mditem.py", line 154, in get_mditem_metadata
    return [CFDate_to_datetime(x) for x in value]
TypeError: '__NSTaggedDate' object is not iterable
RhetTbull commented 2 years ago

This appears to be due to a malformed kMDItemDownloadedDate value left over from early testing. However, it does highlight the fact that osxmetadata probably shouldn't barf on malformed data but gracefully handle the errors.

RhetTbull commented 2 years ago

Fixed in v1.1.0