X-Git-Url: http://git.pjr.cc/?p=glcas.git;a=blobdiff_plain;f=plugins%2Frepo.php;fp=plugins%2Frepo.php;h=f794c29496f6aa3a03faf9264e0eb8cf88804625;hp=9d1de84d177dfa49ff1923ad184391ca336b30b3;hb=143c8289c2a75a9ff8d1db6136baa56fbb8ac19f;hpb=ce6eddc1cf6b4a879b9239fec18258b99f3d739a diff --git a/plugins/repo.php b/plugins/repo.php index 9d1de84..f794c29 100644 --- a/plugins/repo.php +++ b/plugins/repo.php @@ -63,7 +63,23 @@ class GLCASRepo { } echo " - Expire time is ".$repo["expiretime"]." days, checking repo
"; $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
"; + $this->updateRepo($rkey); + } else { + echo " - Up to date
"; + } } } } @@ -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;