From dfa45a1b64f59515a0b62f0912250fa1cf08b8b9 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 27 Jul 2012 10:29:32 +0300 Subject: [PATCH] Make sure that symlinks point to the right place --- source/copy.cpp | 2 ++ source/installedfile.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/copy.cpp b/source/copy.cpp index 0073320..75d047d 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -87,6 +87,8 @@ void Copy::Worker::main() if(!link.empty()) { FS::Path relpath = FS::relative(dst_path, FS::dirname(link)); + if(FS::exists(link)) + FS::unlink(link); symlink(relpath.str().c_str(), link.str().c_str()); } diff --git a/source/installedfile.cpp b/source/installedfile.cpp index 4638cc4..76e7b69 100644 --- a/source/installedfile.cpp +++ b/source/installedfile.cpp @@ -55,8 +55,17 @@ void InstalledFile::check_rebuild() mark_rebuild(source.get_name()+" has changed"); else if(source.needs_rebuild()) mark_rebuild(source.get_name()+" needs rebuilding"); - else if(!link.empty() && !FS::exists(link)) - mark_rebuild("Symlink does not exist"); + if(!needs_rebuild() && !link.empty()) + { + if(!FS::exists(link)) + mark_rebuild("Symlink does not exist"); + else + { + FS::Path rel_path = FS::relative(path, FS::dirname(link)); + if(FS::readlink(link)!=rel_path) + mark_rebuild("Symlink needs updating"); + } + } } void InstalledFile::clean() -- 2.45.2