Skip to content

Commit

Permalink
[WebUI] Fix progress divide by 0 error with empty dir
Browse files Browse the repository at this point in the history
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: #439
  • Loading branch information
freddy2659 authored and cas-- committed Jan 21, 2024
1 parent b7450b5 commit 7f70d6c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deluge/ui/web/json_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,10 @@ def _on_got_files(self, torrent, d):

progresses = dirinfo.setdefault('progresses', [])
progresses.append(torrent_file['size'] * torrent_file['progress'] / 100)
dirinfo['progress'] = sum(progresses) / dirinfo['size'] * 100
if dirinfo['size'] > 0:
dirinfo['progress'] = sum(progresses) / dirinfo['size'] * 100
else:
dirinfo['progress'] = 100
dirinfo['path'] = dirname
dirname = os.path.dirname(dirname)

Expand Down

0 comments on commit 7f70d6c

Please sign in to comment.