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.
This commit is contained in:
Michael Lotz
2017-11-05 23:04:09 +01:00
parent 346d149694
commit 93596e8037
+5 -2
View File
@@ -15,6 +15,7 @@
#include <Entry.h>
#include <ObjectList.h>
#include <Path.h>
#include <String.h>
#include <package/hpkg/HPKGDefs.h>
@@ -312,6 +313,9 @@ command_update(int argc, const char* const* argv)
return 1;
}
BEntry tempRepositoryFile(tempRepositoryFileName.String());
BPath targetRepositoryFilePath(targetRepositoryFileName);
BObjectList<BString> 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,