From 2f2d8f10c0b96524c6380b18a89845016632a53b Mon Sep 17 00:00:00 2001
From: Pawel Wieczorek
Date: Fri, 5 Dec 2014 15:26:24 +0100
Subject: [PATCH] Extend ignored files list in integrity mechanism
Integrity mechanism will not remove file containing checksums even
though it is not listed in database index.
Change-Id: I1e587ecdad5abff47d78362394cc0ecdb1ecd4c4
---
src/storage/Integrity.cpp | 14 +++++++++++---
src/storage/Integrity.h | 3 +++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/storage/Integrity.cpp b/src/storage/Integrity.cpp
index 82e8f5a..5dfa624 100644
--- a/src/storage/Integrity.cpp
+++ b/src/storage/Integrity.cpp
@@ -109,9 +109,8 @@ void Integrity::deleteNonIndexedFiles(BucketPresenceTester tester) {
while (errno = 0, (direntPtr = readdir(dirPtr)) != nullptr) {
std::string filename = direntPtr->d_name;
- //ignore all special files (working dir, parent dir, index)
- if ("." == filename || ".." == filename ||
- PathConfig::StoragePath::indexFilename == filename) {
+ //ignore all special files (working dir, parent dir, index, checksums)
+ if (isSpecialDirectory(filename) || isSpecialDatabaseEntry(filename)) {
continue;
}
@@ -236,4 +235,13 @@ void Integrity::deleteHardLink(const std::string &filename) {
}
}
+bool Integrity::isSpecialDirectory(const std::string &filename) {
+ return "." == filename || ".." == filename;
+}
+
+bool Integrity::isSpecialDatabaseEntry(const std::string &filename) {
+ return PathConfig::StoragePath::indexFilename == filename ||
+ PathConfig::StoragePath::checksumFilename == filename;
+}
+
} /* namespace Cynara */
diff --git a/src/storage/Integrity.h b/src/storage/Integrity.h
index d06eada..2917fb3 100644
--- a/src/storage/Integrity.h
+++ b/src/storage/Integrity.h
@@ -58,6 +58,9 @@ protected:
static void createHardLink(const std::string &oldName, const std::string &newName);
static void deleteHardLink(const std::string &filename);
+ static bool isSpecialDirectory(const std::string &filename);
+ static bool isSpecialDatabaseEntry(const std::string &filename);
+
private:
const std::string m_dbPath;
static const std::string m_indexFilename;
--
2.7.4