Manager: Fix symbolic link pulling and pushing

This commit is contained in:
Riyyi
2022-03-02 15:43:20 +01:00
parent cf27699c00
commit 3ed700863a
+10 -2
View File
@@ -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);
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);