Index: trunk/ippScripts/scripts/publish_file.pl
===================================================================
--- trunk/ippScripts/scripts/publish_file.pl	(revision 28395)
+++ trunk/ippScripts/scripts/publish_file.pl	(revision 28413)
@@ -140,6 +140,11 @@
     print $dsFile "$file|||$product|$name|\n";
 
-} elsif ($stage eq 'diff') {
-    my $command =  "difftool -diffskyfile -diff_id $stage_id";
+} elsif ($stage eq 'diff' or $stage eq 'diffphot') {
+    my $command;                # Command to run
+    if ($stage eq 'diff') {
+        $command = "difftool -diffskyfile -diff_id $stage_id";
+    } elsif ($stage eq 'diffphot') {
+        $command = "diffphottool -data -diff_phot_id $stage_id";
+    }
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -147,12 +152,10 @@
     &my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $success;
 
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    my $components = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
 
-    my $components = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
-
-    my ($mopsPositiveFile, $mopsPositiveFileName) = tempfile("/tmp/publish.$pub_id.mops.pos.XXXX", UNLINK => !$save_temps ) if $product eq 'IPP-MOPS';
-    my ($mopsNegativeFile, $mopsNegativeFileName) = tempfile("/tmp/publish.$pub_id.mops.neg.XXXX", UNLINK => !$save_temps ) if $product eq 'IPP-MOPS';
+    my $mops = ($product =~ /^IPP-MOPS/ ? 1 : 0); # Format for MOPS?
+    my ($mopsPositiveFile, $mopsPositiveFileName) = tempfile("/tmp/publish.$pub_id.mops.pos.XXXX", UNLINK => !$save_temps ) if $mops;
+    my ($mopsNegativeFile, $mopsNegativeFileName) = tempfile("/tmp/publish.$pub_id.mops.neg.XXXX", UNLINK => !$save_temps ) if $mops;
 
     my %positive;               # Data for positive diff detections
@@ -169,5 +172,10 @@
 
         my $skycell_id = $comp->{skycell_id};
-        my $filename = $ipprc->filename( "PPSUB.OUTPUT.SOURCES", $path_base );
+        my $filename;
+        if ($stage eq 'diff') {
+            $filename = $ipprc->filename( "PPSUB.OUTPUT.SOURCES", $path_base );
+        } elsif ($stage eq 'diffphot') {
+            $filename = $ipprc->filename( "PSPHOT.OUT.CMF.MEF", "$path_base.pos" );
+        }
         $filename = $ipprc->file_resolve($filename);
 
@@ -187,5 +195,5 @@
         diff_check(\%positive, $data, "positive");
 
-        if ($product eq 'IPP-MOPS') {
+        if ($mops) {
             print $mopsPositiveFile "$filename\n";
         } else {
@@ -195,5 +203,11 @@
         # Negative direction
         if (defined $comp->{bothways} and $comp->{bothways}) {
-            my $filename = $ipprc->filename( "PPSUB.INVERSE.SOURCES", $path_base );
+            my $filename;
+            if ($stage eq 'diff') {
+                $filename = $ipprc->filename( "PPSUB.INVERSE.SOURCES", $path_base );
+            } elsif ($stage eq 'diffphot') {
+                $filename = $ipprc->filename( "PSPHOT.OUT.CMF.MEF", "$path_base.neg" );
+            }
+
             $filename = $ipprc->file_resolve($filename);
 
@@ -213,5 +227,5 @@
             diff_check(\%negative, $data, "negative");
 
-            if ($product eq 'IPP-MOPS') {
+            if ($mops) {
                 print $mopsNegativeFile "$filename\n";
             } else {
@@ -221,8 +235,8 @@
     }
 
-    close $mopsPositiveFile if $product eq 'IPP-MOPS';
-    close $mopsNegativeFile if $product eq 'IPP-MOPS';
-
-    if ($product eq 'IPP-MOPS') {
+    close $mopsPositiveFile if $mops;
+    close $mopsNegativeFile if $mops;
+
+    if ($mops) {
         if (scalar keys %positive > 0) {
             my $output = mops_combine(\%positive, "$outroot.pos.mops", $mopsPositiveFileName);
