Index: /trunk/ippScripts/scripts/magic_process.pl
===================================================================
--- /trunk/ippScripts/scripts/magic_process.pl	(revision 20706)
+++ /trunk/ippScripts/scripts/magic_process.pl	(revision 20707)
@@ -235,4 +235,36 @@
     }
 }
+if ($node eq "root") {
+    my $streaks_file = "$outroot.streaks";
+    my $resolved = $ipprc->file_resolve($streaks_file);
+
+    my $fh;
+    open $fh, "<$resolved" or 
+        &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
+    # the first line in the streaks file contains the number of streaks found
+    my $num_streaks = <$fh>;
+    chomp $num_streaks;
+    close $fh;
+    print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
+    
+    my $command = "$magictool -addmask";
+    $command   .= " -magic_id $magic_id";
+    $command   .= " -uri $streaks_file";
+    $command   .= " -streaks $num_streaks";
+    $command   .= " -dbname $dbname" if defined $dbname;
+
+    # Add the processed file to the database
+    unless ($no_update) {
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run(command => $command, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            # This isn't going to work because our result was already entered.
+            &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code);
+        }
+    } else {
+        print "Skipping command: $command\n";
+    }
+}
 
 
@@ -304,10 +336,3 @@
 }
 
-END {
-    my $status = $?;
-    system("sync") == 0
-        or die "failed to execute sync: $!" ;
-    $? = $status;
-}
-
 __END__
