updating apt repo's now work.... apt really annoys
[glcas.git] / plugins / repo.php
index 9d1de84..f794c29 100644 (file)
@@ -63,7 +63,23 @@ class GLCASRepo {
                                }
                                echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
                                $maxtdiff = $repo["expiretime"] * 24 * 3600;
-                               $this->updateRepo($rkey);
+                               // now we check for outdated release files
+                               $dh = opendir("$repostore/$rkey/dists/");
+                               $needsupdate = false;
+                               while(($fn = readdir($dh))!==false) {
+                                       if($fn != "." && $fn != "..") {
+                                               if(file_exists("$repostore/$rkey/dists/$fn/Release")) {
+                                                       $tdiff = time() -  filemtime("$repostore/$rkey/dists/$fn/Release");
+                                                       if($tdiff > $maxtdiff) $needsupdate = true;
+                                               }
+                                       }
+                               }
+                               if($needsupdate) {
+                                       echo " - Spawn updater<br>";
+                                       $this->updateRepo($rkey);
+                               } else {
+                                       echo " - Up to date<br>";
+                               }
                        }
                }
        }
@@ -795,6 +811,13 @@ class GLCASRepo {
                if(!file_exists("$repostore/$repokey")) {
                        mkdir("$repostore/$repokey");
                }
+               
+               if(!file_exists("$repostore/$repokey/dists/")) {
+                       mkdir("$repostore/$repokey/dists/");
+                       // no point trying to update if we have no dists directory
+                       return;
+               }
+               
 
                error_log("background apt repo update, start");
                global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;