From 3ed700863a89ee9a8c7e0e1a082354c2ee816af2 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 2 Mar 2022 15:37:46 +0100 Subject: [PATCH] Manager: Fix symbolic link pulling and pushing --- src/dotfile.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dotfile.cpp b/src/dotfile.cpp index c954c24..0d69881 100644 --- a/src/dotfile.cpp +++ b/src/dotfile.cpp @@ -173,7 +173,6 @@ void Dotfile::sync(SyncType type, } auto printError = [](const std::filesystem::path& path, const std::error_code& error) -> void { - // std::filesystem::copy doesnt respect 'overwrite_existing' for symlinks if (error.value() && error.message() != "File exists") { fprintf(stderr, "\033[31;1mDotfile:\033[0m '%s': %c%s\n", path.c_str(), @@ -210,8 +209,17 @@ void Dotfile::sync(SyncType type, if (Config::the().verbose()) { printf("'%s' -> '%s'\n", from.c_str(), to.c_str()); } - std::filesystem::copy(from, to, copyOptions, error); - printError(to, error); + if (std::filesystem::is_symlink(from)) { + // NOTE: std::filesystem::copy doesnt respect 'overwrite_existing' for symlinks + std::filesystem::remove(to, error); + printError(to, error); + std::filesystem::copy_symlink(from, to, error); + printError(from, error); + } + else { + std::filesystem::copy(from, to, copyOptions, error); + printError(from, error); + } if (homePath && root) { seteuid(0);