Skip to content

Commit

Permalink
Reverting changes on Upload class in uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
jrods committed Oct 25, 2016
1 parent 8c5298d commit 0045b84
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions ckan/lib/uploader.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/action/update.py
Expand Up @@ -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'):
Expand All @@ -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})
Expand Down

0 comments on commit 0045b84

Please sign in to comment.