about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-06-14 03:43:26 +0530
committerAndinus <andinus@nand.sh>2020-06-14 03:43:26 +0530
commitb7784f7a14ca75a9f2d86572b6b60211aad78e41 (patch)
tree98e64700af7385386d4a7414d06d6fd1717f74bb
parente4519b936b779b4534179430c977ebdc627b9e9a (diff)
downloadara-b7784f7a14ca75a9f2d86572b6b60211aad78e41.tar.gz
Enforce local option
Till now the local option was actually useless, this enforces it.

The program will only not respect local option if the file doesn't
exist. Otherwise in all cases it shall respect the option.
-rwxr-xr-xara.pl15
1 files changed, 9 insertions, 6 deletions
diff --git a/ara.pl b/ara.pl
index 3f59efa..7836f6f 100755
--- a/ara.pl
+++ b/ara.pl
@@ -100,20 +100,23 @@ foreach my $path ( sort keys %unveil ) {
 my $file = "$cache_dir/ara.json";
 my $file_mtime;
 
-# If $file exists then get ctime.
+# If $file exists then get mtime.
 if ( -e $file ) {
     my $file_stat = path($file)->stat;
     $file_mtime = Time::Moment->from_epoch( $file_stat->mtime );
 } else {
-    warn "File '$file' doesn't exist\nFetching latest...\n"
-        if $use_local_file;
+    if ( $use_local_file ) {
+        warn "File '$file' doesn't exist\nFetching latest...\n";
+        undef $use_local_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 $get_latest ) {
+if ( not $use_local_file
+         and ( not -e $file
+               or $file_mtime < Time::Moment->now_utc->minus_minutes(8)
+               or $get_latest ) ) {
     require HTTP::Simple;
 
     no warnings 'once';