Fix refresh of cache in case of empty file

This commit is contained in:
Florent 2012-03-13 17:14:04 +01:00
commit 0cf5a2b8c5

View file

@ -110,6 +110,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") {
} }
} }
else { else {
my $refresh;
my $first = 1; my $first = 1;
my $time = time(); my $time = time();
# Check if cache exist and not older than 3 hours # Check if cache exist and not older than 3 hours
@ -118,9 +119,12 @@ else {
LOOP: while(<CACHE>) { LOOP: while(<CACHE>) {
if ($first) { if ($first) {
if ($time - $_ > $refreshtime) { if ($time - $_ > $refreshtime) {
$cache = 0; $refresh = 0;
last; last;
} }
else {
$refresh = 1;
}
$first = 0; $first = 0;
} }
else { else {
@ -129,7 +133,7 @@ else {
} }
} }
close(CACHE); close(CACHE);
exit if $cache; exit if $cache and $refresh;
# Open cache for writing and execute weboob # Open cache for writing and execute weboob
open(CACHE, "> " . $cachefile) or die "Failed to open file $cachefile"; open(CACHE, "> " . $cachefile) or die "Failed to open file $cachefile";