1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +00:00

Fix bug in repo_file_get

This commit is contained in:
xiez 2012-08-10 10:43:51 +08:00
parent aca8a7309f
commit a99ed91e49

View File

@ -853,12 +853,15 @@ def repo_file_get(raw_path):
file_response = urllib2.urlopen(raw_path)
if long(file_response.headers['Content-Length']) > FILE_PREVIEW_MAX_SIZE:
err = '文件超过10M无法在线查看。'
return err, '', ''
else:
content = file_response.read()
except urllib2.HTTPError, e:
err = 'HTTPError: 无法在线打开该文件'
return err, '', ''
except urllib2.URLError as e:
err = 'URLError: 无法在线打开该文件'
return err, '', ''
else:
try:
u_content = content.decode('utf-8')