Validate file before continuing.

Signed-off-by: droy <denis.roy@eclipse.org>
diff --git a/mir_trend.php b/mir_trend.php
index 3e59b8b..bcb0775 100644
--- a/mir_trend.php
+++ b/mir_trend.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
-* Copyright (c) 2006-2015 Eclipse Foundation and others.
+* Copyright (c) 2006-2016 Eclipse Foundation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
@@ -40,9 +40,9 @@
   $mirror = new Mirror();
 
   # Load up file index
-  # We only need one file, but we'll fetch 100 and exit as soon as one is found
-  # on disk
+  # We only need one file, but we'll fetch 100 and exit as soon as one is found on disk
   $drop_list = array();
+  $valid_file = false;
   $sql = "SELECT file_name, IF(size_disk_bytes BETWEEN 2000000 AND 5000000, 1, 0) AS ideal_size, IF(size_disk_bytes BETWEEN 250000 AND 10000000, 1, 0) AS almost_ideal_size, size_disk_bytes
         FROM download_file_index WHERE timestamp_disk > 0 order by ideal_size*RAND() desc, almost_ideal_size*RAND() desc, size_disk_bytes asc limit 100";
   $rs_idx = mysql_query($sql, $dbh);
@@ -51,9 +51,13 @@
     $drop_list['EclipseFull']['size_disk_bytes'] = $myrow_idx['size_disk_bytes'];
 
     if(file_exists($app->getDownloadBasePath() . $myrow_idx['file_name']) && !$mirror->isExcluded($myrow_idx['file_name'])) {
+      $valid_file = true;
       break;
     }
   }
+  if(!$valid_file) {
+    die("ERROR: Unable to locate a valid file to trend!");
+  }
 
 
   # instead of inserting trend records as we go along, we will put the sql queries into an array