#69 Division by zero when syncing remote to local

Malfunction
open
nobody
s3cmd (118)
5
2013-02-19
2010-10-16
Mike Morearty
No

I did a sync from remote to local, and there were no files out of date. The following error was reported:

Problem: ZeroDivisionError: float division
S3cmd: 0.9.9.91

Traceback (most recent call last):
File "/cygdrive/c/Users/Margaret/bin/s3cmd", line 1737, in <module>
main()
File "/cygdrive/c/Users/Margaret/bin/s3cmd", line 1682, in main
cmd_func(args)
File "/cygdrive/c/Users/Margaret/bin/s3cmd", line 1071, in cmd_sync
return cmd_sync_remote2local(args)
File "/cygdrive/c/Users/Margaret/bin/s3cmd", line 917, in cmd_sync_remote2loca
l
speed_fmt = formatSize(total_size/total_elapsed, human_readable = True, floa
ting_point = True)
ZeroDivisionError: float division

The error is caused by "total_size/total_elapsed" in s3cmd line 917, which is in cmd_sync_remote2local.

It looks like someone already fixed the same issue in cmd_sync_local2remote, because that function protects against divide by zero:

total\_speed = total\_elapsed and total\_size/total\_elapsed or 0.0
speed\_fmt = formatSize\(total\_speed, human\_readable = True, floating\_point = True\)

cmd_sync_remote2local needs similar code.

Discussion