I've made a script to calculate the size of current path.
def getFolderSize(path):
total_size = os.path.getsize(path)
for item in os.listdir(path):
itempath = os.path.join(path, item)
if os.path.isfile(itempath):
total_size += os.path.getsize(itempath)
elif os.path.isdir(itempath):
total_size += getFolderSize(itempath)
return total_size
However, when I run du it shows me completely different result.
def du(path):
return subprocess.check_output(['du','-sh', path]).split()[0].decode('utf-8')
How those two functions differs and what might cause such distinguish in results?