From 93596e8037d47bf865fec286977b9b37c7a75c87 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 5 Nov 2017 21:12:43 +0100 Subject: [PATCH] package_repo: Fix update command when used with relative target. Renaming of the temporary repo file failed when used with a relative target path. The path was appended twice in such a case. Also when used with a specified base directory, the relative temporary repo file wasn't reachable from the changed working directory. To fix both cases, create the BEntry pointing at the temporary repo file before changing the directory and rename it using only the target leaf name. --- src/bin/package_repo/command_update.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/package_repo/command_update.cpp b/src/bin/package_repo/command_update.cpp index 5da5772c53..3e06ee69cb 100644 --- a/src/bin/package_repo/command_update.cpp +++ b/src/bin/package_repo/command_update.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -312,6 +313,9 @@ command_update(int argc, const char* const* argv) return 1; } + BEntry tempRepositoryFile(tempRepositoryFileName.String()); + BPath targetRepositoryFilePath(targetRepositoryFileName); + BObjectList packageNames(100, true); if ((result = parsePackageListFile(packageListFileName, &packageNames)) != B_OK) { @@ -378,8 +382,7 @@ command_update(int argc, const char* const* argv) if (result != B_OK) return 1; - result = BEntry(tempRepositoryFileName.String()).Rename( - targetRepositoryFileName, true); + result = tempRepositoryFile.Rename(targetRepositoryFilePath.Leaf(), true); if (result != B_OK) { printf("Error: unable to rename repository %s to %s - %s\n", tempRepositoryFileName.String(), targetRepositoryFileName,