Ticket #13531: django-find-size-without-name.diff
File django-find-size-without-name.diff, 1006 bytes (added by , 14 years ago) |
---|
-
django/core/files/base.py
35 35 def _get_size(self): 36 36 if not hasattr(self, '_size'): 37 37 if hasattr(self.file, 'size'): 38 self._size = self.file.size 39 elif os.path.exists(self.file.name):38 self._size = self.file.size 39 elif hasattr(self.file, 'name') and os.path.exists(self.file.name): 40 40 self._size = os.path.getsize(self.file.name) 41 41 else: 42 raise AttributeError("Unable to determine the file's size.") 42 try: 43 self.file.seek(0, 2) 44 self._size = self.file.tell() 45 except IOError: 46 raise AttributeError("Unable to determine the file's size.") 43 47 return self._size 44 48 45 49 def _set_size(self, size):