mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
[views.py] fixed bug in repo_file_get
This commit is contained in:
8
views.py
8
views.py
@@ -1417,15 +1417,15 @@ def repo_file_get(raw_path):
|
|||||||
file_response = urllib2.urlopen(raw_path)
|
file_response = urllib2.urlopen(raw_path)
|
||||||
if long(file_response.headers['Content-Length']) > FILE_PREVIEW_MAX_SIZE:
|
if long(file_response.headers['Content-Length']) > FILE_PREVIEW_MAX_SIZE:
|
||||||
err = _(u'File size surpasses 10M, can not be previewed online.')
|
err = _(u'File size surpasses 10M, can not be previewed online.')
|
||||||
return err, '', '', ''
|
return err, '', ''
|
||||||
else:
|
else:
|
||||||
content = file_response.read()
|
content = file_response.read()
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
err = _(u'HTTPError: failed to open file online')
|
err = _(u'HTTPError: failed to open file online')
|
||||||
return err, '', '', ''
|
return err, '', ''
|
||||||
except urllib2.URLError as e:
|
except urllib2.URLError as e:
|
||||||
err = _(u'URLError: failed to open file online')
|
err = _(u'URLError: failed to open file online')
|
||||||
return err, '', '', ''
|
return err, '', ''
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
u_content = content.decode('utf-8')
|
u_content = content.decode('utf-8')
|
||||||
@@ -1437,7 +1437,7 @@ def repo_file_get(raw_path):
|
|||||||
encoding = 'gbk'
|
encoding = 'gbk'
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
err = _(u'Unknown file encoding')
|
err = _(u'Unknown file encoding')
|
||||||
return err, '', '', ''
|
return err, '', ''
|
||||||
|
|
||||||
file_content = u_content
|
file_content = u_content
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user