Incorrectly reporting free space

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
RiskyShift
Newbie
Newbie
Posts: 5
Joined: August 15th, 2008, 5:51 am

Incorrectly reporting free space

Post by RiskyShift »

There is a bug on Windows which leads to SABnzbd+ incorrectly reporting the amount of free disk space. I have a NAS which has 4TB of space, with about 970GB used and SAB reported -908GB free (yes, a negative amount of free space). This was quite annoying because it kept auto-pausing. After a bit of investigation it appears it is because diskfree() uses GetDiskFreeSpace() to find the free space, which is quite an outdated function and doesn't work very well with very large volumes:

Code: Select all

>>> import win32api
>>> win32api.GetDiskFreeSpace('z:/')
(2, 512, -951626036, -1)
I found the way to fix it is to use GetDiskFreeSpaceEx() instead, which does work:

Code: Select all

>>> win32api.GetDiskFreeSpaceEx('z:/')
(3423581450240L, 4464200622080L, 3423581450240L)
So to fix it I modified SABnzbd+ like so:

Code: Select all

--- sabnzbd\interface.py.orig	2009-02-05 13:39:48.656250000 +0000
+++ sabnzbd\interface.py    	2009-02-05 14:46:52.265625000 +0000
@@ -89,14 +89,14 @@
     # windows diskfree
     def diskfree(_dir):
         try:
-            secp, byteper, freecl, noclu = win32api.GetDiskFreeSpace(_dir)
-            return (secp * byteper * freecl) / GIGI
+            available, disk_size, total_free = win32api.GetDiskFreeSpaceEx(_dir)
+            return available / GIGI
         except:
             return 0.0
     def disktotal(_dir):
         try:
-            secp, byteper, freecl, noclu = win32api.GetDiskFreeSpace(_dir)
-            return (secp * byteper * noclu) / GIGI
+            available, disk_size, total_free = win32api.GetDiskFreeSpaceEx(_dir)
+            return disk_size / GIGI
         except:
             return 0.0
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Incorrectly reporting free space

Post by shypike »

Thanks for the tip, I'll file a ticket for it so we can include it in the next release.

Ticket = https://trac2.assembla.com/SABnzbd/ticket/227
Last edited by shypike on February 5th, 2009, 10:35 am, edited 1 time in total.
Post Reply