Issue 157: Force download of preview if file is large

This commit is contained in:
Nathan Adams 2016-05-01 15:44:43 -05:00
parent cc88235d78
commit 5d37f6fa6c

View File

@ -211,7 +211,9 @@ class IDF_Views_Source
if ($request_file_info->type != 'tree') {
$info = self::getRequestedFileMimeType($request_file_info,
$commit, $scm);
if (!IDF_FileUtil::isText($info) && !IDF_FileUtil::isImage($info)) {
$previewSizeLimit = Pluf::f("preview_size_limit", 2000000);
if (!IDF_FileUtil::isText($info) && !IDF_FileUtil::isImage($info) ||
(!IDF_FileUtil::isImage($info) && $request_file_info->size >= $previewSizeLimit)) {
$rep = new Pluf_HTTP_Response($scm->getFile($request_file_info),
$info[0]);
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$info[1].'"';