forked from lix-project/lix
* Atomic file replacement is good.
This commit is contained in:
parent
e1e9c036f9
commit
2fdb27e7f2
|
@ -199,9 +199,17 @@ foreach my $p (keys %dstOutPaths) {
|
|||
my $finalName =
|
||||
"$narBz2Hash-$name-$closestVersion-to-$version.nar-diff";
|
||||
|
||||
system("cp '$tmpdir/DIFF' '$patchesDir/$finalName'") == 0
|
||||
if (-e "$patchesDir/$finalName") {
|
||||
print " not copying, already exists\n";
|
||||
next;
|
||||
}
|
||||
|
||||
system("cp '$tmpdir/DIFF' '$patchesDir/$finalName.tmp'") == 0
|
||||
or die "cannot copy diff";
|
||||
|
||||
rename("$patchesDir/$finalName.tmp", "$patchesDir/$finalName")
|
||||
or die "cannot rename $patchesDir/$finalName.tmp";
|
||||
|
||||
# Add the patch to the manifest.
|
||||
addPatch \%dstPatches, $p,
|
||||
{ url => "$patchesURL/$finalName", hash => $narBz2Hash
|
||||
|
|
|
@ -146,7 +146,7 @@ sub writeManifest
|
|||
my $patches = shift;
|
||||
my $successors = shift;
|
||||
|
||||
open MANIFEST, ">$manifest";
|
||||
open MANIFEST, ">$manifest.tmp"; # !!! check exclusive
|
||||
|
||||
foreach my $storePath (keys %{$narFiles}) {
|
||||
my $narFileList = $$narFiles{$storePath};
|
||||
|
@ -184,6 +184,9 @@ sub writeManifest
|
|||
|
||||
|
||||
close MANIFEST;
|
||||
|
||||
rename("$manifest.tmp", $manifest)
|
||||
or die "cannot rename $manifest.tmp: $!";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue