[WebUI] Fix progress divide by 0 error with empty dir
If a dir exists with no contents then the following error occurred: ``` Traceback (most recent call last): ... File "/usr/lib/python3.10/site-packages/deluge/ui/web/json_api.py", line 608, in _on_got_files dirinfo['progress'] = sum(progresses) / dirinfo['size'] * 100 builtins.ZeroDivisionError: float division by zero ``` Closes: https://github.com/deluge-torrent/deluge/pull/439
This commit is contained in:
parent
b7450b5082
commit
7f70d6c6ff
|
@ -600,7 +600,10 @@ class WebApi(JSONComponent):
|
||||||
|
|
||||||
progresses = dirinfo.setdefault('progresses', [])
|
progresses = dirinfo.setdefault('progresses', [])
|
||||||
progresses.append(torrent_file['size'] * torrent_file['progress'] / 100)
|
progresses.append(torrent_file['size'] * torrent_file['progress'] / 100)
|
||||||
|
if dirinfo['size'] > 0:
|
||||||
dirinfo['progress'] = sum(progresses) / dirinfo['size'] * 100
|
dirinfo['progress'] = sum(progresses) / dirinfo['size'] * 100
|
||||||
|
else:
|
||||||
|
dirinfo['progress'] = 100
|
||||||
dirinfo['path'] = dirname
|
dirinfo['path'] = dirname
|
||||||
dirname = os.path.dirname(dirname)
|
dirname = os.path.dirname(dirname)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue