Opened 14 years ago

Closed 10 years ago

#2303 closed defect (fixed)

unnecessary checkout for getting file size

Reported by: sascha_silbe Owned by: alsroot
Priority: Urgent Milestone: Unspecified
Component: Sugar Version: Git as of bugdate
Severity: Minor Keywords:
Cc: Distribution/OS:
Bug Status: New


From jarabe.journal.expandedentry.ExpandedEntry._create_technical():

             _('Size: %s') % (format_size(int(self._metadata.get('filesize',

dict.get() doesn't short-circuit evaluation, so model.get_file_size() will always get evaluated, even if self._metadata contains filesize.

Change History (7)

comment:1 Changed 14 years ago by sascha_silbe

This is what I use in the version support branch now:

        filesize = self._metadata.get('filesize')
        if filesize is None:
            object_id = (self._metadata['tree_id'], self._metadata['version_id'])
            filesize = model.get_file_size(object_id)

        lines = [
            _('Kind: %s') % (self._metadata.get('mime_type') or _('Unknown'),),
            _('Date: %s') % (self._format_date(),),
            _('Size: %s') % (format_size(int(filesize))),

Feel free to adapt for mainline.

comment:2 Changed 11 years ago by dnarvaez

  • Component changed from journal to sugar

comment:3 Changed 11 years ago by dnarvaez

  • Milestone changed from 0.90 to Unspecified

comment:4 Changed 10 years ago by dnarvaez

  • Bug Status changed from Unconfirmed to New
  • Priority changed from Unspecified by Maintainer to Urgent

comment:5 Changed 10 years ago by dnarvaez

  • Priority changed from Urgent to High

comment:6 Changed 10 years ago by dnarvaez

  • Priority changed from High to Urgent

comment:7 Changed 10 years ago by godiard

  • Resolution set to fixed
  • Status changed from new to closed

Fixed by 035cadb48626b70ed5561a6e61239b820d393bbd

Note: See TracTickets for help on using tickets.