Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2013-01-17 18:12:06 (GMT)
committer Manuel QuiƱones <manuq@laptop.org>2013-02-19 01:44:01 (GMT)
commite4ddc6dbb1695911679d4cbcd21ee29f108c386b (patch)
treec367a6da9b11312fa02887890e5ae30eeb4ca859
parent7d17637f35842c10cf0a8532a5438b731054bfb9 (diff)
Correct amount in free space error message SL #394
Fixed the order of operation to calculate the free space amount to show in the error message. Added some comments on the code about the units (Bytes, Kilobytes) used by each method. Signed-off-by: Manuel Kaufmann <humitos@gmail.com> Acked-by: Manuel QuiƱones <manuq@laptop.org>
-rw-r--r--downloadmanager.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/downloadmanager.py b/downloadmanager.py
index 155864a..1e4f92b 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -38,7 +38,7 @@ DS_DBUS_PATH = '/org/laptop/sugar/DataStore'
_active_downloads = []
_dest_to_window = {}
-SPACE_THRESHOLD = 52428800
+SPACE_THRESHOLD = 52428800 # 50 Mb
def can_quit():
@@ -112,8 +112,8 @@ class Download(object):
'to download')
total_size_mb = total_size / 1024.0 ** 2
- free_space_mb = self._free_available_space(
- path=self.temp_path) - SPACE_THRESHOLD \
+ free_space_mb = (self._free_available_space(
+ path=self.temp_path) - SPACE_THRESHOLD) \
/ 1024.0 ** 2
filename = self._download.get_suggested_filename()
self._canceled_alert.props.msg = \
@@ -236,7 +236,7 @@ class Download(object):
def enough_space(self, size, path='/'):
"""Check if there is enough (size) free space on path
- size -- free space requested in Kb
+ size -- free space requested in Bytes
path -- device where the check will be done. For example: '/tmp'
@@ -250,6 +250,12 @@ class Download(object):
return free_space - size > SPACE_THRESHOLD
def _free_available_space(self, path='/'):
+ """Return available space in Bytes
+
+ This method returns the available free space in the 'path' and
+ returns this amount in Bytes.
+ """
+
s = os.statvfs(path)
return s.f_bavail * s.f_frsize