Index: trunk/ippScripts/scripts/receive_file.pl
===================================================================
--- trunk/ippScripts/scripts/receive_file.pl	(revision 24038)
+++ trunk/ippScripts/scripts/receive_file.pl	(revision 24102)
@@ -36,5 +36,5 @@
 
 # Parse the command-line arguments
-my ( $file_id, $source, $product, $fileset, $fileset_id, $file, $workdir, $dbname, $verbose, $no_update, $save_temps );
+my ( $file_id, $source, $product, $fileset, $fileset_id, $file, $component, $bytes, $md5sum, $workdir, $dbname, $verbose, $no_update, $save_temps );
 
 GetOptions(
@@ -45,4 +45,7 @@
            'fileset_id=s'      => \$fileset_id, # database id for the fileset
            'file=s'            => \$file, # File to retrieve
+           'component=s'       => \$component, # component for this file (class_id, skycell_id or dbinfo)
+           'bytes=i'           => \$bytes, # file size in bytes
+           'md5sum=s'          => \$md5sum, # md5sum for file from data store
            'workdir=s'         => \$workdir, # Working directory for output
            'dbname=s'          => \$dbname,    # Database name
@@ -60,4 +63,7 @@
     defined $fileset and
     defined $file and
+    defined $component and
+    defined $bytes and
+    defined $md5sum and
     defined $workdir;
 
@@ -72,8 +78,10 @@
     my $uri = "$source/$product/$fileset/$file"; # URI for datastore file
     my $command = "dsget --uri $uri --filename $filename"; # Command to execute
+    $command .= " --timeout 590";
+    $command .= " --bytes $bytes --md5 $md5sum";
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
-    die "Unable to retrieve file from $uri\n" unless $success;
+    &my_die( "Unable to retrieve file from $uri\n", $file_id, $PS_EXIT_DATA_ERROR) unless $success;
 }
 my $mjd_copy = DateTime->now->mjd;   # MJD of finishing copy
@@ -87,8 +95,8 @@
     my $fixFile;
 
-    open $fixFile, ">$fixName" or die "can't open $fixName\n";
+    open $fixFile, ">$fixName" or &my_die( "can't open $fixName\n", $file_id, $PS_EXIT_UNKNOWN_ERROR);
 
     # Need to fix paths to point to new workdir
-    open my $inFile, $filename or die "Can't open $filename\n"; # Input file
+    open my $inFile, $filename or &my_die( "Can't open $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); # Input file
     my $workdir_old;            # Old workdir
     while (<$inFile>) {
@@ -112,5 +120,5 @@
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
-    die "Unable to set dbinfo_uri for $fileset_id to  $fixName\n" unless $success;
+    &my_die( "Unable to set dbinfo_uri for $fileset_id to  $fixName\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success;
 #}
 
@@ -122,5 +130,5 @@
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
-        die "Unable to get listing of tar file $filename\n" unless $success;
+        &my_die( "Unable to get listing of tar file $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success;
 
         my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output
@@ -140,5 +148,5 @@
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
-        die "Unable to extract tar file $filename\n" unless $success;
+        &my_die( "Unable to extract tar file $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success;
     }
 
@@ -148,11 +156,11 @@
         my $target = "$workdir/$file"; # Target destination for file
         my $to = $ipprc->file_create( $target ); # Target for move
-        system("mv $from $to") == 0 or die "Unable to move $file into workdir $workdir: $!\n";
+        system("mv $from $to") == 0 or &my_die( "Unable to move $file into workdir $workdir: $!\n", $file_id, $PS_EXIT_UNKNOWN_ERROR);
     }
 } else {
-    die "Unrecognised file: $file\n";
-}
-
-unlink $filename or die "Unable to unlink $filename\n";
+    &my_die( "Unrecognised file: $file\n", $file_id, $PS_EXIT_UNKNOWN_ERROR);
+}
+
+unlink $filename or &my_die( "Unable to unlink $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR);
 my $mjd_extract = DateTime->now->mjd;   # MJD of finishing extract
 
