Bug 479280 - download.php is adding files to download_file_index that do
not exist
Signed-off-by: droy <denis.roy@eclipse.org>
diff --git a/download.php b/download.php
index 120a0bd..5cc52c0 100755
--- a/download.php
+++ b/download.php
@@ -185,6 +185,14 @@
$log_download = false;
}
+ # Bypass the entire SQL statement if we're getting a HEAD request
+ # Bug 479280
+ if($_SERVER['REQUEST_METHOD'] == "HEAD") {
+ $no_mirror = true;
+ if($_debug == 1) echo "HEAD request -- not querying mirrors.<br />";
+ $log_download = false;
+ }
+
# Don't send a mirror list if the request comes from within our network
if(substr($remote_addr, 0, 10) == "198.41.30."
|| !$Mirror->isValidPublicIP($remote_addr)) {
@@ -290,14 +298,10 @@
$sha1sum = $myrow['sha1sum'];
$sha512sum = $myrow['sha512sum'];
}
-
- # Still no file_id? Then this is the first time this file is seen (bug 379376)
- if($file_id == 0 || $file_id == "" && $log_download) {
- $file_id = &addFileToIndex($_file);
- }
}
+
# No file time in the index. Check the filesystem
- if($filetime == 0) {
+ if($filetime == 0 || $file_id == 0 || $file_id == "") {
if($_debug == 1) {
echo "Checking filesystem for $filename time.<br />";
}
@@ -336,6 +340,10 @@
return false;
}
else {
+ # we finally have a filetime after examining disk. Add it to the index if we're logging downloads.
+ if($log_download) {
+ $file_id = &addFileToIndex($_file);
+ }
if($Friend->getIsCommitter() || $Friend->getIsBenefit()) {
$file_name = preg_replace("/download\.eclipse\.org/", "archive.eclipse.org", $app->getDownloadBasePath() . $_file);
if(file_exists($file_name)) {