Index: trunk/ippScripts/scripts/magic_destreak.pl
===================================================================
--- trunk/ippScripts/scripts/magic_destreak.pl	(revision 29495)
+++ trunk/ippScripts/scripts/magic_destreak.pl	(revision 29561)
@@ -42,5 +42,5 @@
 # Parse the command-line arguments
 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction);
-my ($streaks_path_base, $inv_streaks_path_base);
+my ($streaks_path_base, $inv_streaks_path_base, $run_state);
 my ($outroot, $recoveryroot, $magicked);
 my ($replace, $release);
@@ -50,4 +50,5 @@
            'magic_ds_id=s'  => \$magic_ds_id,# Magic destreak run identifier
            'camera=s'       => \$camera,     # camera for evaluating file rules
+           'run-state=s'    => \$run_state,   # state of run (new or update)
            'streaks_path_base=s'      => \$streaks_path_base,    # path_base for streaks data
            'inv_streaks_path_base=s'  => \$inv_streaks_path_base, #path_base for streaks from inverse diff
@@ -77,8 +78,9 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --magic_ds_id --camera --streaks --stage --stage_id --component --uri --path_base --outroot --magicked",
+pod2usage( -msg => "Required options: --magic_ds_id --camera --run_state --streaks --stage --stage_id --component --uri --path_base --outroot --magicked",
            -exitval => 3) unless
     defined $magic_ds_id and
     defined $camera and
+    defined $run_state and
     defined $streaks and
     defined $streaks_path_base and
@@ -113,4 +115,8 @@
     &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
 }
+
+&my_die("Invalid value for run-state: $run_state", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
+    unless ($run_state eq 'new') or ($run_state eq 'update');
+
 $inv_streaks_path_base = undef if defined($inv_streaks_path_base) and ($inv_streaks_path_base eq "NULL");
 $inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL");
@@ -479,11 +485,16 @@
 # Input result into database
 {
-    my $command = "$magicdstool -adddestreakedfile";
+    my $command = "$magicdstool";
     $command   .= " -magic_ds_id $magic_ds_id";
     $command   .= " -component $component";
     $command   .= " -setmagicked" if $replace;
-    $command   .= " -backup_path_base $backup_path_base" if $backup_path_base;
-    $command   .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;
-    $command   .= " $statsFlags" if $statsFlags;
+    if ($run_state eq 'new') {
+        $command .= " -adddestreakedfile";
+        $command .= " -backup_path_base $backup_path_base" if $backup_path_base;
+        $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;
+        $command .= " $statsFlags" if $statsFlags;
+    } else {
+        $command .= " -tofullfile";
+    }
     $command   .= " -dbname $dbname" if defined $dbname;
 
@@ -581,5 +592,11 @@
     $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
 
-    my $command = "$magicdstool -adddestreakedfile";
+    my $command = "$magicdstool";
+    
+    if ($run_state eq 'new') {
+        $command .= " -adddestreakedfile";
+    } else {
+        $command .= " -updatedestreakedfile";
+    }
     $command   .= " -magic_ds_id $magic_ds_id";
     $command   .= " -component $component";
