

def save(self, *args, **kwargs):
    if ((not self.id) and (not self.created)):
        self.created = timezone.now()
    self.type = self.determine_file_type(self.file.name)
    if self.file:
        try:
            self.file_size = self.file.size
        except (OSError, IOError, ValueError) as e:
            logger.error(('Unable to read file size for %s: %s' % (self, e)))
    super(MediaFileBase, self).save(*args, **kwargs)
    logger.info(('Saved mediafile %d (%s, type %s, %d bytes)' % (self.id, self.file.name, self.type, (self.file_size or 0))))
    if getattr(self, '_original_file_name', None):
        if (self.file.name != self._original_file_name):
            self.delete_mediafile(self._original_file_name)
    self.purge_translation_cache()

dataset/ETHPy150Open feincms/feincms/feincms/module/medialibrary/models.py MediaFileBase.save/original