From 5d37f6fa6c3a11397277cdf36ccac99184ddb1d3 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 1 May 2016 15:44:43 -0500 Subject: [PATCH] Issue 157: Force download of preview if file is large --- indefero/src/IDF/Views/Source.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indefero/src/IDF/Views/Source.php b/indefero/src/IDF/Views/Source.php index abb584a..6c1a5a4 100644 --- a/indefero/src/IDF/Views/Source.php +++ b/indefero/src/IDF/Views/Source.php @@ -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].'"';