I had a corrupted tar file (due to interruption while writing last file …).
I needed to append to archive and it was not possible (I had tarfile.ReadError: empty header
as soon as I opened the archive in append mode.
Problem : the archive had 1M°+ files all flat (it was intended to use directly).
This script save my day, and was quite fast (Note how opening the big tar is expensive: 9 minutes !):
2022-05-17T15:52:17.492944 starting
2022-05-17T16:03:01.681669 0 done, 0 errs
2022-05-17T16:05:01.001833 100000 done, 0 errs