about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-06-10 17:31:37 +0530
committerAndinus <andinus@nand.sh>2020-06-10 17:31:37 +0530
commit94bdc8e40d765ad087753edfa48bb061b087a761 (patch)
tree58984bd130bcb520ce35d6c8f4ec276af11c61cf
parentfcd6004951ff78735e3b428be0b69ff915b951cd (diff)
downloadara-94bdc8e40d765ad087753edfa48bb061b087a761.tar.gz
Use ctime instead of mtime to compare
HTTP::Tiny sets mtime to "Last Modified" time set by the server. ctime
is set as the time when that file gets created on disk so we use that
to compare now, actually this should've been used from the start but
File::Fetch didn't set mtime differently (?) so mtime worked till we
used File::Fetch.
-rwxr-xr-xara.pl6
1 files changed, 3 insertions, 3 deletions
diff --git a/ara.pl b/ara.pl
index a351eb6..93656a4 100755
--- a/ara.pl
+++ b/ara.pl
@@ -61,12 +61,12 @@ foreach my $path ( sort keys %unveil ) {
 }
 
 my $file = '/tmp/data.json';
-my $file_mtime;
+my $file_ctime;
 
 # If $file exists then get mtime.
 if ( -e $file ) {
     my $file_stat = path($file)->stat;
-    $file_mtime = Time::Moment->from_epoch( $file_stat->[9] );
+    $file_ctime = Time::Moment->from_epoch( $file_stat->[10] );
 } else {
     warn "File '$file' doesn't exist\nFetching latest...\n"
         if $use_local_file;
@@ -75,7 +75,7 @@ if ( -e $file ) {
 # Fetch latest data only if the local data is older than 8 minutes or
 # if the file doesn't exist.
 if ( not -e $file
-         or $file_mtime < Time::Moment->now_utc->minus_minutes(8)
+         or $file_ctime < Time::Moment->now_utc->minus_minutes(8)
          or $get_latest ) {
     require HTTP::Tiny;