fixed coding fails from last commit
authorStricted <Stricted@nexus-irc.de>
Mon, 1 Oct 2012 19:05:55 +0000 (21:05 +0200)
committerStricted <Stricted@nexus-irc.de>
Mon, 1 Oct 2012 19:05:55 +0000 (21:05 +0200)
git_download.php

index 697c58757356ff906941e436ce095dd9964a7949..74d3851115615c93d322a102c0ec265fc9b54733 100644 (file)
@@ -53,25 +53,20 @@ if(isset($_GET['p'])){
                }else{
                        $hash = substr(shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"), 0, 7);
                }
-               if(file_exists("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz")) {
-                       header("Content-Type: application/x-gzip");
-                       header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz");
-                       readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
-                       unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
-               }else{
-                       $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build']);
-                       $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']);
-                       $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
-                       if($_GET['build'] != "gitweb.git") {
-                               scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".$hash);
-                       }
-                       $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".$hash.".tar.gz ".$name);
-                       $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
-                       header("Content-Type: application/x-gzip");
-                       header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz");
-                       readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
-                       unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
+               $id = sha1(time());
+               $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build']);
+               $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']);
+               $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
+               if($_GET['build'] != "gitweb.git") {
+                       scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".$hash);
                }
+               $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$id." ".$name);
+               $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
+               header("Content-Type: application/x-gzip");
+               header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz");
+               readfile("/usr/share/gitweb/dl/".$id);
+               unlink("/usr/share/gitweb/dl/".$id);
+               
        }else{
                echo "unknown project";
        }