aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Maximilian Grothusmann <maxi@own-hero.net> 2009-02-01 02:24:00 +0100
committerAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2009-02-01 21:35:14 +0100
commit6495cff03b28792bd5ef8bdb7d97d77a7666a67e (patch)
tree59b39076d82bd2201af31f42e64187b5c8dd303c
parentb9e88dbfab72fd773068c4b8d7293d766300b7cf (diff)
downloadpaludis-6495cff03b28792bd5ef8bdb7d97d77a7666a67e.tar.gz
paludis-6495cff03b28792bd5ef8bdb7d97d77a7666a67e.tar.xz
Fix merging as a hardlink
Since 1c359b6841082de0d5fb9b29719b2c410cb60b0f, hardlinks did not get merged correctly, as it is impossible to overwrite an existing file with link(). Fix this by creating the link with a temporary name and renaming the link over the existing target.
-rw-r--r--paludis/merger.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/paludis/merger.cc b/paludis/merger.cc
index 97625fe..9ec76ac 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -762,8 +762,10 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
_imp->merged_ids.equal_range(src.lowlevel_id()));
for (MergedMap::const_iterator i = ii.first ; i != ii.second ; ++i)
{
- if (0 == ::link(i->second.c_str(), stringify(dst_real).c_str()))
+ if (0 == ::link(i->second.c_str(), stringify(dst).c_str()))
{
+ if (0 != std::rename(stringify(dst).c_str(), stringify(dst_real).c_str()))
+ throw MergerError("rename(" + stringify(dst) + ", " + stringify(dst_real) + ") failed: " + stringify(::strerror(errno)));
do_copy = false;
result += msi_as_hardlink;
break;