summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-07-24 13:33:55 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-07-24 13:33:55 (GMT)
commit2e23e9a5ac9be4164ac1247d5ef6c79318848f7f (patch)
tree1c49e1c595e1ce57289585747072abd7bd77013f
parentd10a643c1f4c9be6c9b3e1211064ef5fba053645 (diff)
safer handling of STAT_FILE
-rwxr-xr-xrhimport-dn13
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;