Fix cleanup of signatures

* Record full path for the deletion of orphaned signatures
* Test for the existence of the signature symlink itself and not the target
  because the symlink target (in the any directory) might not exist anymore
  but the symlink should be removed in any case
This commit is contained in:
Martchus 2021-08-29 00:32:19 +02:00
parent c68202bdc1
commit a93924bb3a
1 changed files with 3 additions and 3 deletions

View File

@ -712,7 +712,7 @@ void CleanRepository::run()
if (fileName.ends_with(".sig")) {
if (!std::filesystem::exists(std::filesystem::symlink_status(
dirInfo.canonicalPath / std::string_view(fileName.data(), fileName.data() + fileName.size() - 4)))) {
dirInfo.toDelete.emplace_back(fileName);
dirInfo.toDelete.emplace_back(repoItem);
}
continue;
}
@ -781,7 +781,7 @@ void CleanRepository::run()
if (!m_dryRun) {
const auto signatureFile = std::filesystem::path(argsToString(toDelete, ".sig"));
std::filesystem::remove(toDelete);
if (std::filesystem::exists(signatureFile)) {
if (std::filesystem::exists(std::filesystem::symlink_status(signatureFile))) {
std::filesystem::remove(signatureFile);
}
}
@ -807,7 +807,7 @@ void CleanRepository::run()
const auto destPath = archiveDir / path.filename();
const auto signatureFile = std::filesystem::path(argsToString(path, ".sig"));
std::filesystem::rename(path, destPath);
if (std::filesystem::exists(signatureFile)) {
if (std::filesystem::exists(std::filesystem::symlink_status(signatureFile))) {
std::filesystem::rename(signatureFile, argsToString(destPath, ".sig"));
}
}