browsing to network drive causes division by zero

Bug #1688696 reported by Daniel Smith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Rapid Photo Downloader
Fix Released
Medium
Damon Lynch

Bug Description

Selecting a network drive as an export destination causes a division by zero error. I think it must break the space calculation. The download photos button is greyed out as a consequence.

2017-05-05 22:00:11 ERROR excepthook.py 67: An unhandled exception occurred
2017-05-05 22:00:11 ERROR excepthook.py 68: Traceback (most recent call last):
  File "/home/daniel/.local/lib/python3.5/site-packages/raphodo/destinationdisplay.py", line 578, in paintEvent
    videos_size_to_download=videos_size_to_download)
  File "/home/daniel/.local/lib/python3.5/site-packages/raphodo/destinationdisplay.py", line 99, in make_body_details
    percent_used = '{0:.0%}'.format(bytes_to_use / bytes_total)
ZeroDivisionError: division by zero

Related branches

Damon Lynch (dlynch3)
Changed in rapid:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Damon Lynch (dlynch3)
Revision history for this message
Damon Lynch (dlynch3) wrote :

Does your file browser correctly report the free space on the destination?

Please attach the log file, thanks.

Damon Lynch (dlynch3)
Changed in rapid:
milestone: none → 0.9.0b5
status: Triaged → Fix Committed
Revision history for this message
Daniel Smith (lavalamp) wrote :

Yes, file browser shows free space correctly.

Revision history for this message
Daniel Smith (lavalamp) wrote :

Yes, file browser shows free space correctly.

Revision history for this message
Damon Lynch (dlynch3) wrote :

If you can share the method / command for mounting the network share, I'll use that info to try to figure out the best way from Python for determining the storage space on it.

Revision history for this message
Daniel Smith (lavalamp) wrote : Re: [Bug 1688696] Re: browsing to network drive causes division by zero

It's an afp mount. Not sure what ubuntu does to mount it. Ends up mounted
at /run/user/1000/gvfs/afp-volume:host=path.to.nas.local,user=daniel,volume=storage

On Sat, May 6, 2017 at 10:44 PM, Damon Lynch <email address hidden> wrote:

> If you can share the method / command for mounting the network share,
> I'll use that info to try to figure out the best way from Python for
> determining the storage space on it.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1688696
>
> Title:
> browsing to network drive causes division by zero
>
> Status in Rapid Photo Downloader:
> Fix Committed
>
> Bug description:
> Selecting a network drive as an export destination causes a division
> by zero error. I think it must break the space calculation. The
> download photos button is greyed out as a consequence.
>
>
> 2017-05-05 22:00:11 ERROR excepthook.py 67: An unhandled exception
> occurred
> 2017-05-05 22:00:11 ERROR excepthook.py 68: Traceback (most recent call
> last):
> File "/home/daniel/.local/lib/python3.5/site-packages/
> raphodo/destinationdisplay.py", line 578, in paintEvent
> videos_size_to_download=videos_size_to_download)
> File "/home/daniel/.local/lib/python3.5/site-packages/
> raphodo/destinationdisplay.py", line 99, in make_body_details
> percent_used = '{0:.0%}'.format(bytes_to_use / bytes_total)
> ZeroDivisionError: division by zero
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/rapid/+bug/1688696/+subscriptions
>

Revision history for this message
Damon Lynch (dlynch3) wrote :

It looks like the Apple File Protocol is built into GIO/gvfs.

Please mount the AFP share, and run the script disk-usage.py (attached to this bug report) like this:

python3 disk-usage.py

Then copy and paste the results into this bug report, thanks.

Revision history for this message
Damon Lynch (dlynch3) wrote :
Revision history for this message
Daniel Smith (lavalamp) wrote :

I modified the script to pass "True" to disk_partitions, as without it it listed only my root filesystem which is not helpful. The last entry is the relevant one. I have a lot of space on my NAS (4TB or so), maybe a library bug? ... (FWIW I'd be totally fine with the program not showing the disk space it thinks it will use in this scenario.)

$ python3 $HOME/Downloads/disk-usage.py
/sys: usage(total=0, used=0, free=0)
/proc: usage(total=0, used=0, free=0)
/dev: usage(total=16773214208, used=0, free=16773214208)
/dev/pts: usage(total=0, used=0, free=0)
/run: usage(total=3358941184, used=10432512, free=3348508672)
/: usage(total=247677222912, used=92294418432, free=142777925632)
/sys/kernel/security: usage(total=0, used=0, free=0)
/dev/shm: usage(total=16794701824, used=372129792, free=16422572032)
/run/lock: usage(total=5242880, used=4096, free=5238784)
/sys/fs/cgroup: usage(total=16794701824, used=0, free=16794701824)
/sys/fs/cgroup/systemd: usage(total=0, used=0, free=0)
/sys/fs/pstore: usage(total=0, used=0, free=0)
/sys/fs/cgroup/devices: usage(total=0, used=0, free=0)
/sys/fs/cgroup/hugetlb: usage(total=0, used=0, free=0)
/sys/fs/cgroup/pids: usage(total=0, used=0, free=0)
/sys/fs/cgroup/cpu,cpuacct: usage(total=0, used=0, free=0)
/sys/fs/cgroup/net_cls,net_prio: usage(total=0, used=0, free=0)
/sys/fs/cgroup/perf_event: usage(total=0, used=0, free=0)
/sys/fs/cgroup/freezer: usage(total=0, used=0, free=0)
/sys/fs/cgroup/blkio: usage(total=0, used=0, free=0)
/sys/fs/cgroup/cpuset: usage(total=0, used=0, free=0)
/sys/fs/cgroup/memory: usage(total=0, used=0, free=0)
/proc/sys/fs/binfmt_misc: usage(total=0, used=0, free=0)
/sys/kernel/debug: usage(total=0, used=0, free=0)
/dev/mqueue: usage(total=0, used=0, free=0)
/dev/hugepages: usage(total=0, used=0, free=0)
/sys/fs/fuse/connections: usage(total=0, used=0, free=0)
/run/user/1000: usage(total=3358941184, used=65536, free=3358875648)
/home/daniel: usage(total=247677222912, used=92294418432, free=142777925632)
/run/user/1000/gvfs: usage(total=0, used=0, free=0)

Revision history for this message
Damon Lynch (dlynch3) wrote :

It's interesting that GIO reports the correct value (that's where your file browser, which I assume is Gnome Files, gets its values from). Can you double check to confirm that Gnome Files displays the correct disk free and total bytes value?

In this instance, both Python and Qt are failing to determine the correct value, which may mean that GVFS is not supplying it correctly to them. That's my guess at least. (Rapid Photo Downloader currently uses Qt to get volume usage; Qt is likely making the same library call as Python).

Revision history for this message
Daniel Smith (lavalamp) wrote :

Yeah, nautilus shows 4.9TB, 2.9TB free, which sounds right.

Revision history for this message
Damon Lynch (dlynch3) wrote :

Let me know if the next beta (beta 5) does not correctly display the size for your network share. It should do so, where the network share is used for either backups or as the primary download destination. Also let me know if the user interface ever appears to freeze (the device space check is not asynchronous, and it's called several times).

Damon Lynch (dlynch3)
Changed in rapid:
status: Fix Committed → Fix Released
Revision history for this message
Daniel Smith (lavalamp) wrote :

Awesome, crash is gone now, thanks!

The UI element now says "Device size unknown", which doesn't bother me at all.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.