diff --git a/ckan/lib/uploader.py b/ckan/lib/uploader.py index a16dc3638c9..f64ea829742 100644 --- a/ckan/lib/uploader.py +++ b/ckan/lib/uploader.py @@ -98,8 +98,6 @@ def __init__(self, object_type, old_filename=None): self.storage_path = None self.filename = None self.filepath = None - self.filesize = 0 # bytes - self.mimetype = None path = get_storage_path() if not path: return @@ -170,18 +168,10 @@ def upload(self, max_size=2): raise logic.ValidationError( {self.file_field: ['File upload too large']} ) - output_file.seek(0, os.SEEK_END) - self.filesize = output_file.tell() output_file.close() os.rename(self.tmp_filepath, self.filepath) self.clear = True - try: - self.mimetype = magic.from_file(filepath, mime=True) - except IOError: - # Not that important if call above fails - self.mimetype = None - if (self.clear and self.old_filename and not self.old_filename.startswith('http')): try: diff --git a/ckan/logic/action/update.py b/ckan/logic/action/update.py index 27b76dbc7b2..0c7c21e8908 100644 --- a/ckan/logic/action/update.py +++ b/ckan/logic/action/update.py @@ -94,7 +94,6 @@ def resource_update(context, data_dict): plugin.before_update(context, pkg_dict['resources'][n], data_dict) upload = uploader.get_resource_uploader(data_dict) - upload.upload(id, uploader.get_max_resource_size()) if not 'mimetype' in data_dict: if hasattr(upload, 'mimetype'): @@ -115,6 +114,7 @@ def resource_update(context, data_dict): errors = e.error_dict['resources'][n] raise ValidationError(errors) + upload.upload(id, uploader.get_max_resource_size()) model.repo.commit() resource = _get_action('resource_show')(context, {'id': id})