Opened 9 years ago

Closed 5 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

Description

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

             _('Size: %s') % (format_size(int(self._metadata.get('filesize',
                                 model.get_file_size(self._metadata['uid']))))),

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 9 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 6 years ago by dnarvaez

  • Component changed from journal to sugar

comment:3 Changed 6 years ago by dnarvaez

  • Milestone changed from 0.90 to Unspecified

comment:4 Changed 6 years ago by dnarvaez

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

comment:5 Changed 6 years ago by dnarvaez

  • Priority changed from Urgent to High

comment:6 Changed 6 years ago by dnarvaez

  • Priority changed from High to Urgent

comment:7 Changed 5 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.