Metron-Project/darkseid

Bad File Error Log Output

Closed this issue · 0 comments

Recently I was doing some bulk changes from CBR to CBZ and ran across some bad files. The output was just a failure and I'm wondering if it is possible to get that changed to a list of bad files and then gracefully moving on?

The concept would be that if a file like this is encountered it can move to the next, output the file name in red at the end of the current command.

$\textcolor{green}{Exported\ 'Action\ Comics\ 228\ (1957).cbr'\ to\ a\ cbz\ archive.}$
$\textcolor{green}{Removing\ 'Action\ Comics\ 228\ (1957).cbr'.}$
$\textcolor{yellow}{'Action\ Comics\ 229\ (1957) (c2c)\ (Superscan).cbz'\ is\ not\ a\ cbr\ archive.\ skipping...}$
$\textcolor{yellow}{'Action\ Comics\ 230\ (1957)\ (c2c)\ (Superscan).cbz'\ is\ not\ a\ cbr\ archive.\ skipping...}$
$\textcolor{red}{Bad\ file\ 'Action\ Comics\ 231\ (1957).cbr`\ user\ intervention\ needed.\ skipping...}$

Below is an error output and I was able to track down the file manually and move on.

Traceback (most recent call last):
  File "/home/suineg/.local/bin/metron-tagger", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/metrontagger/cli.py", line 96, in main
    runner.run()
  File "/home/suineg/.local/lib/python3.12/site-packages/metrontagger/run.py", line 454, in run
    self._export_to_zip(file_list)
  File "/home/suineg/.local/lib/python3.12/site-packages/metrontagger/run.py", line 119, in _export_to_zip
    if ca.export_as_zip(new_fn):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/darkseid/comic.py", line 454, in export_as_zip
    return zip_archiver.copy_from_archive(self._archiver)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/darkseid/archivers/zip.py", line 171, in copy_from_archive
    for filename in other_archive.get_filename_list():
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/darkseid/archivers/rar.py", line 110, in get_filename_list
    with rarfile.RarFile(self.path) as rf:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 711, in __init__
    self._parse()
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 932, in _parse
    self._file_parser.parse()
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 1110, in parse
    self._parse_real()
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 1136, in _parse_real
    h = self._parse_header(fd)
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 1241, in _parse_header
    return self._parse_block_header(fd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 1483, in _parse_block_header
    pos = self._parse_file_header(h, hdata, pos - 4)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 1552, in _parse_file_header
    name, pos = load_bytes(hdata, name_size, pos)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/suineg/.local/lib/python3.12/site-packages/rarfile.py", line 2915, in load_bytes
    raise BadRarFile("cannot load bytes")
rarfile.BadRarFile: cannot load bytes