Skip to content

Commit

Permalink
fix regression when deleting single cache entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemba committed Nov 18, 2024
1 parent d80c451 commit bd071f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION="3.13.0"
VERSION="3.13.1"
37 changes: 22 additions & 15 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,22 +618,24 @@ void Cache::editResources(QSharedPointer<Queue> queue, const QString &command,
}
}
} else if (userInput == "d") {
int b = 0;
QList<int> resIds;
int rIdx = 0;
QList<int> rIdxList;
printf("\033[1;34mWhich resource id would you like to "
"remove?\033[0m (Enter to cancel)\n");
for (auto res : resources) {
for (const auto &res : resources) {
if (res.cacheId == cacheId &&
!binTypes().contains(res.type)) {
printf("\033[1;33m%d\033[0m) \033[1;33m%s\033[0m (%s): "
"'\033[1;32m%s\033[0m'\n",
++b, res.type.toStdString().c_str(),
res.source.toStdString().c_str(),
res.value.toStdString().c_str());
resIds.append(b - 1);
printf(
"\033[1;33m%4d\033[0m) \033[1;33m%s\033[0m (%s): "
"'\033[1;32m%s\033[0m'\n",
rIdxList.length() + 1, res.type.toStdString().c_str(),
res.source.toStdString().c_str(),
res.value.toStdString().c_str());
rIdxList.append(rIdx);
}
rIdx++;
}
if (resIds.isEmpty()) {
if (rIdxList.isEmpty()) {
printf("No resources found, cancelling...\n\n");
continue;
}
Expand All @@ -646,12 +648,17 @@ void Cache::editResources(QSharedPointer<Queue> queue, const QString &command,
continue;
} else {
int chosen = atoi(typeInput.c_str());
if (chosen >= 1 && chosen <= resIds.length()) {
resources.removeAt(resIds.at(
chosen - 1)); // -1 because lists start at 0
printf("<<< Removed resource id %d\n\n", chosen);
if (chosen >= 1 && chosen <= rIdxList.length()) {
int index = rIdxList.at(chosen - 1);
QString delType = resources[index].type;
QString delSource = resources[index].source;
resources.removeAt(index);
printf("<<< Removed resource: %s (%s)\n\n",
delType.toStdString().c_str(),
delSource.toStdString().c_str());

} else {
printf("Incorrect resource id, cancelling...\n\n");
printf("Invalid input, cancelling...\n\n");
}
}
} else if (userInput == "D") {
Expand Down

0 comments on commit bd071f9

Please sign in to comment.