diff options
author | Christian Pointner <equinox@helsinki.at> | 2011-07-24 13:33:55 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2011-07-24 13:33:55 (GMT) |
commit | 261feb0dd80a0ec11aa8b3a6858f7682ac71540c (patch) | |
tree | 1c49e1c595e1ce57289585747072abd7bd77013f | |
parent | 02c5a1891db0bed999866f7cff54179930012b38 (diff) |
safer handling of STAT_FILE
git-svn-id: https://svn.helsinki.at/rhimport/trunk@91 7c65635b-ec39-4f67-a626-873dbafdd612
-rwxr-xr-x | rhimport-dn | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/rhimport-dn b/rhimport-dn index dce71bc..53e1e34 100755 --- a/rhimport-dn +++ b/rhimport-dn @@ -83,6 +83,7 @@ my $feed = XML::Feed->parse(URI->new($RSS_URL)) or die "Error fetching feed: " . XML::Feed->errstr; my $file = ""; +my $out_file = ""; for my $entry ($feed->entries) { if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") { my $sum_title = $entry->title; @@ -99,15 +100,12 @@ for my $entry ($feed->entries) { $dbh->disconnect(); exit 0; } - unlink($STAT_FILE); - open(my $fhs, '>', $STAT_FILE); - print $fhs $ff->output_file; - close($fhs); + $out_file = $ff->output_file; print $1 . ": downloading " . $entry->enclosure->url . " (" . $entry->enclosure->length . " Bytes) .. "; $file = $ff->fetch( to => '/tmp' ) or die $ff->error; print "ok\n"; - + print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n"; push(@PV_SCRIPT, sprintf("%04d-%02d-%02d", $today[0], $today[1], $today[2])); @@ -165,4 +163,9 @@ if(!$ret) { exit 1; } +unlink($STAT_FILE); +open(my $fhs, '>', $STAT_FILE); +print $fhs $out_file; +close($fhs); + exit 0; |