Private GIT

Skip to content
Snippets Groups Projects
Commit 49039790 authored by Nils Vogels's avatar Nils Vogels
Browse files

Corrected faulty filesystem freespace check on non-Windows

parent cc09aa02
Branches
Tags
No related merge requests found
......@@ -1633,13 +1633,17 @@ def isFileLocked(file, writeLockCheck=False):
def getDiskSpaceUsage(diskPath=None):
'''
returns the free space in MB for a given path
returns the free space in MB for a given path or False if no path given
@param diskPath: the filesystem path being checked
'''
if diskPath:
if platform.system() == 'Windows':
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(diskPath), None, None, ctypes.pointer(free_bytes))
return free_bytes.value / 1024 / 1024
else:
st = os.statvfs(sickbeard.TV_DOWNLOAD_DIR)
st = os.statvfs(diskPath)
return st.f_bavail * st.f_frsize / 1024 / 1024
else:
return False
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment