diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-03-20T10·16+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-03-20T10·16+0000 |
commit | f10686811053f79b5c60c97a70dde4f638fad840 (patch) | |
tree | 4ce69b70cf7713b380632f9ec999ad1c48e56009 /scripts/nix-push.in | |
parent | f789ea1d098c2755e97f7ee6ebc418f71e5f56f6 (diff) |
* Cleanup.
Diffstat (limited to 'scripts/nix-push.in')
-rw-r--r-- | scripts/nix-push.in | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in index 137e3112b23b..1c910438fdb2 100644 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -224,13 +224,14 @@ writeManifest $manifest, \%narFiles, \%patches; sub copyFile { my $src = shift; my $dst = shift; - system("@coreutils@/cp", $src, "$dst.tmp") == 0 or die "cannot copy file"; - rename("$dst.tmp", "$dst") or die "cannot rename file"; + my $tmp = "$dst.tmp.$$"; + system("@coreutils@/cp", $src, $tmp) == 0 or die "cannot copy file"; + rename($tmp, $dst) or die "cannot rename file: $!"; } -# Upload the archives. -print STDERR "uploading archives...\n"; +# Upload/copy the archives. +print STDERR "uploading/copying archives...\n"; sub archiveExists { my $name = shift; @@ -244,9 +245,12 @@ foreach my $narArchive (@narArchives) { my $basename = $1; if ($localCopy) { + # Since nix-push creates $dst atomically, if it exists we + # don't have to copy again. + my $dst = "$localArchivesDir/$basename"; if (! -f "$localArchivesDir/$basename") { print STDERR " $narArchive\n"; - copyFile $narArchive, "$localArchivesDir/$basename"; + copyFile $narArchive, $dst; } } else { |