Ticket #394: 0001-Correct-amount-in-free-space-error-message-SL-394.patch

File 0001-Correct-amount-in-free-space-error-message-SL-394.patch, 2.2 KB (added by humitos, 10 years ago)
  • downloadmanager.py

    From 0f10f13141ea0432bb067e7eaefd07817dcff161 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Thu, 17 Jan 2013 15:12:06 -0300
    Subject: [PATCH Browse] 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>
    ---
     downloadmanager.py | 14 ++++++++++----
     1 file changed, 10 insertions(+), 4 deletions(-)
    
    diff --git a/downloadmanager.py b/downloadmanager.py
    index 36bcd43..2fdbaa5 100644
    a b DS_DBUS_PATH = '/org/laptop/sugar/DataStore' 
    3838_active_downloads = []
    3939_dest_to_window = {}
    4040
    41 SPACE_THRESHOLD = 52428800
     41SPACE_THRESHOLD = 52428800  # 50 Mb
    4242
    4343def format_float(f):
    4444    return "%0.2f" % f
    class Download(object): 
    114114                                                     'to download')
    115115
    116116                total_size_mb = total_size / 1024.0 ** 2
    117                 free_space_mb = self._free_available_space(
    118                     path=self.temp_path) - SPACE_THRESHOLD \
     117                free_space_mb = (self._free_available_space(
     118                    path=self.temp_path) - SPACE_THRESHOLD) \
    119119                    / 1024.0 ** 2
    120120                filename = self._download.get_suggested_filename()
    121121                self._canceled_alert.props.msg = \
    class Download(object): 
    241241    def enough_space(self, size, path='/'):
    242242        """Check if there is enough (size) free space on path
    243243
    244         size -- free space requested in Kb
     244        size -- free space requested in Bytes
    245245
    246246        path -- device where the check will be done. For example: '/tmp'
    247247
    class Download(object): 
    255255        return free_space - size > SPACE_THRESHOLD
    256256
    257257    def _free_available_space(self, path='/'):
     258        """Return available space in Bytes
     259
     260        This method returns the available free space in the 'path' and
     261        returns this amount in Bytes.
     262        """
     263
    258264        s = os.statvfs(path)
    259265        return s.f_bavail * s.f_frsize
    260266