mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-19 07:27:56 +00:00
Fix bug in repo_file_get
This commit is contained in:
parent
aca8a7309f
commit
a99ed91e49
3
views.py
3
views.py
@ -853,12 +853,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 = '文件超过10M,无法在线查看。'
|
err = '文件超过10M,无法在线查看。'
|
||||||
|
return err, '', ''
|
||||||
else:
|
else:
|
||||||
content = file_response.read()
|
content = file_response.read()
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
err = 'HTTPError: 无法在线打开该文件'
|
err = 'HTTPError: 无法在线打开该文件'
|
||||||
|
return err, '', ''
|
||||||
except urllib2.URLError as e:
|
except urllib2.URLError as e:
|
||||||
err = 'URLError: 无法在线打开该文件'
|
err = 'URLError: 无法在线打开该文件'
|
||||||
|
return err, '', ''
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
u_content = content.decode('utf-8')
|
u_content = content.decode('utf-8')
|
||||||
|
Loading…
Reference in New Issue
Block a user