[projects/buildlogs] Use the same filters in both cases. Use fpassthru instead of manual reading && echoing.
arekm
arekm at pld-linux.org
Thu May 17 10:36:03 CEST 2018
commit 2454d41c5a0e3e86f8a8abdc4a21ca5de5fe1260
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu May 17 10:36:00 2018 +0200
Use the same filters in both cases. Use fpassthru instead of manual reading && echoing.
index.php | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
---
diff --git a/index.php b/index.php
index 38ffa83..35cbe0d 100644
--- a/index.php
+++ b/index.php
@@ -284,6 +284,21 @@ function file_name()
}
}
+function get_filter($f)
+{
+ if (preg_match("/\.bz2$/", $f)) {
+ if (is_executable("/usr/bin/lbzcat"))
+ $filter = "lbzcat";
+ else
+ $filter = "bzcat";
+ } elseif (preg_match("/\.gz$/", $f)) {
+ $filter = "zcat";
+ } else {
+ $filter = "cat";
+ }
+ return $filter;
+}
+
function dump_log($tail)
{
global $ok, $url, $dist, $arch, $name, $name_url;
@@ -353,13 +368,7 @@ function dump_log($tail)
# what can I say beside PHP suxx? how the fuck should I create
# bidirectional pipe? gotta use wget
- if (preg_match("/\.bz2$/", $f)) {
- $filter = "bzcat";
- } elseif (preg_match("/\.gz$/", $f)) {
- $filter = "zcat";
- } else {
- $filter = "cat";
- }
+ $filter = get_filter($f);
$cmd = "$filter '$root_directory/$f'";
$fd = popen($cmd, "r");
@@ -504,22 +513,11 @@ function dump_text()
echo "# date : " .
date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n";
- if (preg_match("/\.bz2$/", $f)) {
- if (is_executable("/usr/bin/lbzcat"))
- $filter = "lbzcat";
- else
- $filter = "bzcat";
- } elseif (preg_match("/\.gz$/", $f)) {
- $filter = "zcat";
- } else {
- $filter = "cat";
- }
+ $filter = get_filter($f);
- $cmd = "$filter '$root_directory/$f'";
+ $cmd = "$filter '$root_directory/$f'";
$fd = popen($cmd, "r");
- while (($s = fgets($fd, 1000)) != false) {
- echo $s;
- }
+ fpassthru($fd);
pclose($fd);
}
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/buildlogs.git/commitdiff/2454d41c5a0e3e86f8a8abdc4a21ca5de5fe1260
More information about the pld-cvs-commit
mailing list