MangaManagerORG / Manga-Manager

Manga Manager collects useful tools to make managing your manga library easy. (Acts directly on files)
GNU General Public License v3.0
192 stars 18 forks source link

Skip a file if it's corrupted on webp converted #115

Closed Roshri closed 1 year ago

Roshri commented 1 year ago

Sometimes I leave a big batch converting before sleeping and it gets truncated at 30% because of a bad zip file so I was wondering if instead of stopping midway the process could just skip the file and then report which files errored out so I can take a closer look at those.

Sometimes it's just a headers error (I got this headers error when unzipping the file with 7-zip)

Traceback (most recent call last):
  File "C:\CommandLineTools\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "C:\Users\roshr\Documents\WindowsPowerShell\Manga-Manager-develop\MangaManager\CommonLib\WebpConverter.py", line 367, in start
    self._process(cbzFilepath, self._tmpname)
  File "C:\Users\roshr\Documents\WindowsPowerShell\Manga-Manager-develop\MangaManager\CommonLib\WebpConverter.py", line 415, in _process
    zout.writestr(file_name + ".webp", convertToWebp(open_zipped_file))
  File "C:\Users\roshr\Documents\WindowsPowerShell\Manga-Manager-develop\MangaManager\CommonLib\WebpConverter.py", line 39, in convertToWebp
    image = Image.open(image_bytes_to_convert).convert()
  File "C:\CommandLineTools\Python\Python310\lib\site-packages\PIL\Image.py", line 889, in convert
    self.load()
  File "C:\CommandLineTools\Python\Python310\lib\site-packages\PIL\ImageFile.py", line 235, in load
    s = read(self.decodermaxblock)
  File "C:\CommandLineTools\Python\Python310\lib\site-packages\PIL\JpegImagePlugin.py", line 402, in load_read
    s = self.fp.read(read_bytes)
  File "C:\CommandLineTools\Python\Python310\lib\zipfile.py", line 925, in read
    data = self._read1(n)
  File "C:\CommandLineTools\Python\Python310\lib\zipfile.py", line 1001, in _read1
    data = self._decompressor.decompress(data, n)
zlib.error: Error -3 while decompressing data: invalid stored block lengths

Often I get this other error but it does skip the file i think?

It's usually a bad download or a corrupted zip file where one of the images is 0B.

Traceback (most recent call last):
  File "C:\Users\roshr\Documents\WindowsPowerShell\Manga-Manager-develop\MangaManager\CommonLib\WebpConverter.py", line 367, in start
    self._process(cbzFilepath, self._tmpname)
  File "C:\Users\roshr\Documents\WindowsPowerShell\Manga-Manager-develop\MangaManager\CommonLib\WebpConverter.py", line 415, in _process
    zout.writestr(file_name + ".webp", convertToWebp(open_zipped_file))
  File "C:\Users\roshr\Documents\WindowsPowerShell\Manga-Manager-develop\MangaManager\CommonLib\WebpConverter.py", line 39, in convertToWebp
    image = Image.open(image_bytes_to_convert).convert()
  File "C:\CommandLineTools\Python\Python310\lib\site-packages\PIL\Image.py", line 889, in convert
    self.load()
  File "C:\CommandLineTools\Python\Python310\lib\site-packages\PIL\ImageFile.py", line 235, in load
    s = read(self.decodermaxblock)
  File "C:\CommandLineTools\Python\Python310\lib\site-packages\PIL\JpegImagePlugin.py", line 402, in load_read
    s = self.fp.read(read_bytes)
  File "C:\CommandLineTools\Python\Python310\lib\zipfile.py", line 925, in read
    data = self._read1(n)
  File "C:\CommandLineTools\Python\Python310\lib\zipfile.py", line 1015, in _read1
    self._update_crc(data)
  File "C:\CommandLineTools\Python\Python310\lib\zipfile.py", line 943, in _update_crc
    raise BadZipFile("Bad CRC-32 for file %r" % self.name)