From b66b3f00179c8f8c439ad6b2dcfb3e56500cceaa Mon Sep 17 00:00:00 2001 From: Esteban RM Date: Sun, 18 Aug 2024 13:43:44 -0300 Subject: [PATCH] Fix overwrite+remove deleting the wrong file on relative path. Issue was caused by updater.pathToNewFile() fetching the path directly from zSyncClient, which will keep absolute paths as-is and change relative paths to be different than the parameter value would be. --- src/cli/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 7501307..5450c7c 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -60,7 +60,9 @@ int main(const int argc, const char** argv) { optional pathToAppImage = [&args]() { if (!args.pos.empty()) { - return optional(args.as(0)); + // calculate absolute path to normalize the path for when it's + // checked back from Updater::pathToNewFile + return optional(abspath(args.as(0))); } return optional(); @@ -240,6 +242,9 @@ int main(const int argc, const char** argv) { return 1; } + // normalize against pathToAppImage - so they follow the same format + newFilePath = abspath(newFilePath); + auto validationResult = updater.validateSignature(); while (updater.nextStatusMessage(nextMessage))