about summary refs log tree commit diff
path: root/perl/lib/Nix/CopyClosure.pm
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-10T15·44+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-10T15·44+0200
commit7c3a5090bff4e9cfe70f1d89619563b55af13d89 (patch)
tree5e127387138029dfe5d4687ff28141e17b658483 /perl/lib/Nix/CopyClosure.pm
parent43b64f503844a66c344780a11289678a001572db (diff)
nix-copy-closure: Fix --dry-run
Diffstat (limited to 'perl/lib/Nix/CopyClosure.pm')
-rw-r--r--perl/lib/Nix/CopyClosure.pm16
1 files changed, 8 insertions, 8 deletions
diff --git a/perl/lib/Nix/CopyClosure.pm b/perl/lib/Nix/CopyClosure.pm
index 5085ec075b96..53da72038d64 100644
--- a/perl/lib/Nix/CopyClosure.pm
+++ b/perl/lib/Nix/CopyClosure.pm
@@ -78,6 +78,13 @@ sub copyTo {
     my @missing = grep { !$present{$_} } @closure;
     return if !@missing;
 
+    my $missingSize = 0;
+    $missingSize += (queryPathInfo($_, 1))[3] foreach @missing;
+
+    printf STDERR "copying %d missing paths (%.2f MiB) to ‘$sshHost’...\n",
+        scalar(@missing), $missingSize / (1024.0^2);
+    return if $dryRun;
+
     # Send the "import paths" command.
     syswrite($to, pack("L<x4", 4)) or die;
     writeString($compressor, $to);
@@ -85,11 +92,7 @@ sub copyTo {
     if ($compressor || $progressViewer) {
 
         # Compute the size of the closure for the progress viewer.
-        if ($progressViewer) {
-            my $missingSize = 0;
-            $missingSize += (queryPathInfo($_, 1))[3] foreach @missing;
-            $progressViewer = "$progressViewer -s $missingSize";
-        }
+        $progressViewer = "$progressViewer -s $missingSize" if $progressViewer;
 
         # Start the compressor and/or progress viewer in between us
         # and the remote host.
@@ -107,9 +110,6 @@ sub copyTo {
     }
 
     readInt($from) == 1 or die "remote machine \`$sshHost' failed to import closure\n";
-
-    # Shut down the server process.
-    waitpid $pid, 0;
 }