]> granicus.if.org Git - pgbadger/commitdiff
Fix incorrect location of temporary file stroring last parsed line in multiprocess...
authorDarold Gilles <gilles@darold.net>
Tue, 22 Jul 2014 16:50:27 +0000 (18:50 +0200)
committerDarold Gilles <gilles@darold.net>
Tue, 22 Jul 2014 16:50:27 +0000 (18:50 +0200)
pgbadger

index 85868d7b65ddad34423f9a337948628a7daf28c0..24b8f46d4d990bf8de8f42c336c11c389599e0a8 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -217,8 +217,8 @@ sub wait_child
                        unlink("$f->[1]") if (-e "$f->[1]");
                }
        }
-       if ($last_parsed && -e $tmp_last_parsed) {
-               unlink("$tmp_last_parsed");
+       if ($last_parsed && -e "$TMP_DIR/$tmp_last_parsed") {
+               unlink("$TMP_DIR/$tmp_last_parsed");
        }
        if ($last_parsed && -e "$last_parsed.tmp") {
                unlink("$last_parsed.tmp");
@@ -808,6 +808,7 @@ my $t0 = Benchmark->new;
 
 # Automatically set parameters with incremental mode
 if ($incremental) {
+
        # In incremental mode an output directory must be set
        if (!$outdir) {
                die "FATAL: you must specify an output directory with incremental mode, see -O or --outdir.\n"
@@ -995,7 +996,7 @@ if ( ($queue_size > 1) || ($job_per_file > 1) ) {
 
 # Get last line parsed from all process
 if ($last_parsed) {
-       if (open(IN, "$tmp_last_parsed") ) {
+       if (open(IN, "$TMP_DIR/$tmp_last_parsed") ) {
                while (my $line = <IN>) {
                        chomp($line);
                        my ($d, $p, $l) = split(/\t/, $line, 3);
@@ -1011,7 +1012,7 @@ if ($last_parsed) {
                }
                close(IN);
        }
-       unlink("$tmp_last_parsed");
+       unlink("$TMP_DIR/$tmp_last_parsed");
 }
 
 # Save last line parsed
@@ -2094,14 +2095,14 @@ sub process_file
 
        # Save last line into temporary file
        if ($last_parsed && scalar keys %last_line) {
-               if (open(OUT, ">>$tmp_last_parsed")) {
+               if (open(OUT, ">>$TMP_DIR/$tmp_last_parsed")) {
                        flock(OUT, 2) || return $getout;
                        $last_line{current_pos} ||= 0;
 
                        print OUT "$last_line{datetime}\t$last_line{current_pos}\t$last_line{orig}\n";
                        close(OUT);
                } else {
-                       &logmsg('ERROR', "can't save last parsed line into $tmp_last_parsed, $!");
+                       &logmsg('ERROR', "can't save last parsed line into $TMP_DIR/$tmp_last_parsed, $!");
                }
        }