From d55d34e0704152eb69260d2944bb78534c3149b1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 7 Oct 2013 14:46:27 +0000 Subject: fixed detection if current file already imported 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); -- cgit v0.10.2