diff options
author | Christian Pointner <equinox@helsinki.at> | 2013-10-07 14:46:27 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2013-10-07 14:46:27 (GMT) |
commit | d55d34e0704152eb69260d2944bb78534c3149b1 (patch) | |
tree | d42662f61bf76cfe23f48ec1f131e13bf4d4985f | |
parent | 381933e505369c61cc971dc2226b4920b494af07 (diff) |
fixed detection if current file already imported
-rwxr-xr-x | rhimport-fw | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/rhimport-fw b/rhimport-fw index 35bedf7..7109198 100755 --- a/rhimport-fw +++ b/rhimport-fw @@ -87,9 +87,18 @@ my @import_date_reb = Date::Calc::Add_Delta_Days(@import_date, 4); print "day of next broadcast: " . Date::Calc::Date_to_Text(@import_date) . "\n"; print "day of next rebroadcast: " . Date::Calc::Date_to_Text(@import_date_reb) . "\n"; +my $id = sprintf("%04d-%02d-%02d", @import_date); my $bnum = `cat $LAST_FILE`; $bnum += 1; +my $current_stat = `cat $STAT_FILE`; +my ($current_id, $current_file) = $current_stat =~ m/^(.*)\n(.*)/; +if($current_id eq $id) { + print "Already downloaded current file\n"; + $dbh->disconnect(); + exit 0; +} + print "looking for file with number $bnum in RSS Feed\n"; print " -> $RSS_URL\n"; @@ -124,7 +133,7 @@ for my $entry ($feed->entries) { my $current_file = `cat $STAT_FILE`; if($current_file eq $ff->output_file) { - print "Already downloaded file of today\n"; + print "Already downloaded current file\n"; $dbh->disconnect(); exit 0; } @@ -191,7 +200,7 @@ if(!$ret) { unlink($STAT_FILE); open(my $fhs, '>', $STAT_FILE); -print $fhs $out_file; +print $fhs "$id\n$out_file"; close($fhs); unlink($LAST_FILE); |