Refined the regex to check if the state file is well formed; changed “graceTime” from 1 year to 3 years; changed the help text accordingly; bumped version to 0.5.2
This commit is contained in:
parent
26533c94c8
commit
980f742271
1 changed files with 5 additions and 4 deletions
|
@ -18,7 +18,7 @@
|
|||
|
||||
$SNAME='GancioF2F';
|
||||
$ENAME=strtolower($SNAME);
|
||||
$SVERS='0.5.1';
|
||||
$SVERS='0.5.2';
|
||||
|
||||
require __DIR__.'/lib/ckmkeys.php';
|
||||
require __DIR__.'/lib/gettlds.php';
|
||||
|
@ -86,7 +86,7 @@ fedi_token = w6oQ_Ot2LSAm_Q31hrvp0asfl22ip3O4ipYq1kV1ceY
|
|||
# «state_file_absolute_path» is required to specify the absolute path of the
|
||||
# state file where {$SNAME} will store the references to already posted
|
||||
# announcements (on every run, {$SNAME} will check this file for entries older
|
||||
# than one year and discard them, to avoid the state file to grow too much).
|
||||
# than 3 years and discard them, to avoid the state file to grow too much).
|
||||
# For example:
|
||||
state_file_absolute_path = /var/local/cache/ganciof2f/gancio.some.domain.state
|
||||
|
||||
|
@ -322,12 +322,13 @@ if (file_exists($conf['state_file_absolute_path'])) {
|
|||
if (!is_readable($conf['state_file_absolute_path'])) dieYoung("Error: «{$conf['state_file_absolute_path']}» exists but it’s not readable.\n",1);
|
||||
if (!is_writeable($conf['state_file_absolute_path'])) dieYoung("Error: «{$conf['state_file_absolute_path']}» exists but it’s not writable.\n",1);
|
||||
$refs=[];
|
||||
$graceTime=365*24*60*60;
|
||||
$graceTime=365*3*24*60*60;
|
||||
$graceLine=time()-$graceTime;
|
||||
$i=0;
|
||||
$buff=file($conf['state_file_absolute_path'],FILE_IGNORE_NEW_LINES);
|
||||
foreach ($buff as $key=>$val) {
|
||||
if (preg_match('#^(\S+)\t(\S+)\t(\d+)$#',$val,$matches)===1) {// todo: refine the pattern
|
||||
//incontro-aperto-mensile-3 2024-10-04T13:33:45.331Z 1730206671
|
||||
if (preg_match('#^([a-z0-9-_]+)\t(\d{4,}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)\t(\d+)$#',$val,$matches)===1) {
|
||||
if ($matches[3]+0>=$graceLine)
|
||||
$refs[$matches[1]]=['updatedAt'=>$matches[2], 'postedAt'=>$matches[3]];
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue