From 0e966a64085ab50913e9afb7a40d1e0b8c3b6a44 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 23 Mar 2022 23:16:25 +0100 Subject: [PATCH] Manager: Fix error message when copying files unprivileged --- src/dotfile.cpp | 4 ++-- src/dotfile.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dotfile.cpp b/src/dotfile.cpp index 1099582..9135511 100644 --- a/src/dotfile.cpp +++ b/src/dotfile.cpp @@ -67,7 +67,7 @@ void Dotfile::add(const std::vector& targets) } sync( - SyncType::Pull, targets, homeIndices, systemIndices, + SyncType::Add, targets, homeIndices, systemIndices, [](std::string* paths, const std::string& homePath, const std::string& homeDirectory) { paths[0] = homePath; paths[1] = homePath.substr(homeDirectory.size() + 1); @@ -291,7 +291,7 @@ void Dotfile::sync(SyncType type, if (!systemIndices.empty() && !root) { for (size_t i : systemIndices) { fprintf(stderr, "\033[31;1mDotfile:\033[0m need root privileges to copy system file '%s'\n", - paths.at(i).c_str() + Config::the().workingDirectorySize()); + paths.at(i).c_str() + (type == SyncType::Add ? 0 : Config::the().workingDirectorySize())); } return; } diff --git a/src/dotfile.h b/src/dotfile.h index d3bdae4..5c8b608 100644 --- a/src/dotfile.h +++ b/src/dotfile.h @@ -21,6 +21,7 @@ public: virtual ~Dotfile(); enum class SyncType { + Add, Pull, Push, };