apachecn/CDNDrive

下载时出错:image file is truncated

daxiaamo opened this issue · 2 comments

下载时报错:
[2021-02-26 20:23:16] 分块2564/5530下载完毕
Traceback (most recent call last):
File "d:\anaconda3\envs\web\lib\site-packages\PIL\ImageFile.py", line 247, in load
s = read(self.decodermaxblock)
File "d:\anaconda3\envs\web\lib\site-packages\PIL\PngImagePlugin.py", line 896, in load_read
cid, pos, length = self.png.read()
File "d:\anaconda3\envs\web\lib\site-packages\PIL\PngImagePlugin.py", line 162, in read
length = i32(s)
File "d:\anaconda3\envs\web\lib\site-packages\PIL_binary.py", line 75, in i32be
return unpack_from(">I", c, o)[0]
struct.error: unpack_from requires a buffer of at least 4 bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "d:\anaconda3\envs\web\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "d:\anaconda3\envs\web\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\anaconda3\envs\web\Scripts\cdrive.exe_main
.py", line 7, in
File "d:\anaconda3\envs\web\lib\site-packages\CDNDrive_main
.py", line 321, in main
args.func(args)
File "d:\anaconda3\envs\web\lib\site-packages\CDNDrive_main_.py", line 226, in download_handle
for h in hdls: h.result()
File "d:\anaconda3\envs\web\lib\concurrent\futures_base.py", line 435, in result
return self.__get_result()
File "d:\anaconda3\envs\web\lib\concurrent\futures_base.py", line 384, in __get_result
raise self.exception
File "d:\anaconda3\envs\web\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "d:\anaconda3\envs\web\lib\site-packages\CDNDrive_main
.py", line 179, in tr_download
block = encoder.decode(block)
File "d:\anaconda3\envs\web\lib\site-packages\CDNDrive\encoders\PngEncoder.py", line 72, in decode
return self.decode_png(data)
File "d:\anaconda3\envs\web\lib\site-packages\CDNDrive\encoders\PngEncoder.py", line 62, in decode_png
data = img.tobytes()
File "d:\anaconda3\envs\web\lib\site-packages\PIL\Image.py", line 734, in tobytes
self.load()
File "d:\anaconda3\envs\web\lib\site-packages\PIL\ImageFile.py", line 253, in load
raise OSError("image file is truncated") from e
OSError: image file is truncated
[2021-02-26 20:23:33] 分块2561/5530第1次下载失败
[2021-02-26 20:23:35] 分块2565/5530第1次下载失败
[2021-02-26 20:24:53] 分块3175/5530第1次下载失败
[2021-02-26 20:25:33] 分块3626/5530第1次下载失败
[2021-02-26 20:25:34] 分块3634/5530第1次下载失败

我也遇到这这样的问题,请问怎么解决

[2021-10-30 10:23:11] 分块313/500下载完毕
Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\PIL\ImageFile.py", line 237, in load
s = read(self.decodermaxblock)
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\PIL\PngImagePlugin.py", line 896, in load_read
cid, pos, length = self.png.read()
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\PIL\PngImagePlugin.py", line 162, in read
length = i32(s)
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\PIL_binary.py", line 85, in i32be
return unpack_from(">I", c, o)[0]
struct.error: unpack_from requires a buffer of at least 4 bytes for unpacking 4
bytes at offset 0 (actual buffer size is 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\run
py.py", line 194, in run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\run
py.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\Scripts
\cdrive.exe_main
.py", line 7, in
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\CDNDrive_main
.py", line 329, in main
args.func(args)
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\CDNDrive_main
.py", line 232, in download_handle
for h in hdls: h.result()
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\con
current\futures_base.py", line 432, in result
return self.__get_result()
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\con
current\futures_base.py", line 388, in __get_result
raise self.exception
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\con
current\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\CDNDrive_main
.py", line 183, in tr_download
block = encoder.decode(block)
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\CDNDrive\encoders\PngEncoder.py", line 72, in decode
return self.decode_png(data)
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\CDNDrive\encoders\PngEncoder.py", line 62, in decode_png
data = img.tobytes()
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\PIL\Image.py", line 744, in tobytes
self.load()
File "c:\users\administrator\appdata\local\programs\python\python38-32\lib\sit
e-packages\PIL\ImageFile.py", line 243, in load
raise OSError("image file is truncated") from e
OSError: image file is truncated

Tmn07 commented

某个资源下载时也会碰到这个问题。重试了几次,不是出现在固定的某个分块之后。把此链接分享给别人可以成功下载,像是我这边网络问题?这种情况下无法续传,似乎只能重新下载。

[2022-04-05 02:24:54] 分块1478/1657下载完毕
Traceback (most recent call last):
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\PIL\ImageFile.py", line 239, in load
s = read(self.decodermaxblock)
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\PIL\PngImagePlugin.py", line 923, in load_read
cid, pos, length = self.png.read()
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\PIL\PngImagePlugin.py", line 189, in read
length = i32(s)
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\PIL_binary.py", line 85, in i32be
return unpack_from(">I", c, o)[0]
struct.error: unpack_from requires a buffer of at least 4 bytes for unpacking 4 bytes at offset 0 (actual buffer size is 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\runpy.py", line 194, in run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Tmn07.pyenv\pyenv-win\versions\3.8.10\Scripts\CDNDrive.exe_main
.py", line 7, in
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\CDNDrive_main
.py", line 329, in main
args.func(args)
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\CDNDrive_main
.py", line 232, in download_handle
for h in hdls: h.result()
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\concurrent\futures_base.py", line 437, in result
return self.__get_result()
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\concurrent\futures_base.py", line 389, in __get_result
raise self.exception
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\CDNDrive_main
.py", line 183, in tr_download
block = encoder.decode(block)
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\CDNDrive\encoders\PngEncoder.py", line 72, in decode
return self.decode_png(data)
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\CDNDrive\encoders\PngEncoder.py", line 62, in decode_png
data = img.tobytes()
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\PIL\Image.py", line 762, in tobytes
self.load()
File "c:\users\tmn07.pyenv\pyenv-win\versions\3.8.10\lib\site-packages\PIL\ImageFile.py", line 245, in load
raise OSError("image file is truncated") from e
OSError: image file is truncated