Skip to content

Archive timestamp metadata sometimes has no microseconds #282

@camh-

Description

@camh-

Attic has a 1-in-a-million chance of creating an archive that will cause an exception when reading back the repository:

$ python3 -m attic.archiver list /tmp/attic-test
Traceback (most recent call last):
  File "/usr/lib/python3.2/runpy.py", line 161, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python3.2/runpy.py", line 74, in _run_code
    exec(code, run_globals)
  File "/src/git/attic/build/lib.linux-x86_64-3.2/attic/archiver.py", line 740, in <module>
    main()
  File "/src/git/attic/build/lib.linux-x86_64-3.2/attic/archiver.py", line 727, in main
    exit_code = archiver.run(sys.argv[1:])
  File "/src/git/attic/build/lib.linux-x86_64-3.2/attic/archiver.py", line 717, in run
    return args.func(args)
  File "/src/git/attic/build/lib.linux-x86_64-3.2/attic/archiver.py", line 297, in do_list
    for archive in sorted(Archive.list_archives(repository, key, manifest), key=attrgetter('ts')):
  File "attic/archive.py", line 166, in ts
    t, f = self.metadata[b'time'].split('.', 1)
ValueError: need more than 1 value to unpack

This occurs because the python function datetime.datetime.isoformat() is documented to leave off the period and microseconds if the microseconds value is zero. This creates a time string that the archive.Archive.ts property fails to parse as it expects there to be a period and microseconds in the string.

This is 1-in-a-million as if the timestamp has zero microseconds, attic creates archive metadata it cannot parse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions