about summary refs log tree commit diff
path: root/src/nix-env/profiles.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-04-09T09·42+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-04-09T09·42+0200
commit60340ce3e2f793caf1704997a4d7a5a066e9ef24 (patch)
tree09b6e74798faa332bfcbb6142b28e7bcaea562ed /src/nix-env/profiles.cc
parent1711679ea5fd6a37db5a7a1b40eba1f58ad6c999 (diff)
Implement caching of fetchurl/fetchTarball results
ETags are used to prevent redownloading unchanged files.
Diffstat (limited to 'src/nix-env/profiles.cc')
-rw-r--r--src/nix-env/profiles.cc11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/nix-env/profiles.cc b/src/nix-env/profiles.cc
index d8eb0ef5269c..d93d7fd80920 100644
--- a/src/nix-env/profiles.cc
+++ b/src/nix-env/profiles.cc
@@ -116,16 +116,7 @@ void switchLink(Path link, Path target)
     /* Hacky. */
     if (dirOf(target) == dirOf(link)) target = baseNameOf(target);
 
-    Path tmp = canonPath(dirOf(link) + "/.new_" + baseNameOf(link));
-    createSymlink(target, tmp);
-    /* The rename() system call is supposed to be essentially atomic
-       on Unix.  That is, if we have links `current -> X' and
-       `new_current -> Y', and we rename new_current to current, a
-       process accessing current will see X or Y, but never a
-       file-not-found or other error condition.  This is sufficient to
-       atomically switch user environments. */
-    if (rename(tmp.c_str(), link.c_str()) != 0)
-        throw SysError(format("renaming ‘%1%’ to ‘%2%’") % tmp % link);
+    replaceSymlink(target, link);
 }