improve update-time detection
This commit is contained in:
parent
fc28e8c5c8
commit
138a3c3342
24
rebuild.php
24
rebuild.php
@ -192,11 +192,20 @@ class CProject {
|
|||||||
// Identify resources in folder
|
// Identify resources in folder
|
||||||
|
|
||||||
$ls = scandir($this->dir);
|
$ls = scandir($this->dir);
|
||||||
|
$found_real_lastupdate = false;
|
||||||
foreach($ls as $file) {
|
foreach($ls as $file) {
|
||||||
if ($file[0] == '.') continue;
|
if ($file[0] == '.') continue;
|
||||||
|
|
||||||
if ($file == 'README.txt') {
|
if ($file == 'README.txt') {
|
||||||
$this->lastupdate = max($this->lastupdate, filectime($this->dir.$file)); // don't count README updates
|
|
||||||
|
// Guess 'last update' time
|
||||||
|
$matches = [];
|
||||||
|
if (preg_match('~\n(\d\d\d\d-\d\d-\d\d)~', $this->longdesc, $matches)) {
|
||||||
|
// Use first date entry (assumed to be a CHANGELOG)
|
||||||
|
$this->lastupdate = strtotime($matches[1]);
|
||||||
|
$found_real_lastupdate = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$this->longdesc = file_get_contents($this->dir.'README.txt');
|
$this->longdesc = file_get_contents($this->dir.'README.txt');
|
||||||
|
|
||||||
@ -235,11 +244,13 @@ class CProject {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lastupdate = max(
|
if (! $found_real_lastupdate) {
|
||||||
$this->lastupdate,
|
$this->lastupdate = max(
|
||||||
// filectime($this->dir.$file),
|
$this->lastupdate,
|
||||||
filemtime($this->dir.$file)
|
// filectime($this->dir.$file),
|
||||||
);
|
($file == 'README.txt' ? filectime($this->dir.$file) : filemtime($this->dir.$file)) // Don't count README updates
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_image($file)) {
|
if (is_image($file)) {
|
||||||
$this->images[] = $file;
|
$this->images[] = $file;
|
||||||
@ -582,6 +593,7 @@ function main($args) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
ini_set('display_errors', 'On');
|
ini_set('display_errors', 'On');
|
||||||
|
date_default_timezone_set('Etc/UTC');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
main(array_slice($_SERVER['argv'], 1));
|
main(array_slice($_SERVER['argv'], 1));
|
||||||
|
Reference in New Issue
Block a user