Extend ignored files list in integrity mechanism 73/32773/15
authorPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 5 Dec 2014 14:26:24 +0000 (15:26 +0100)
committerPawel Wieczorek <p.wieczorek2@samsung.com>
Thu, 26 Feb 2015 07:45:11 +0000 (08:45 +0100)
Integrity mechanism will not remove file containing checksums even
though it is not listed in database index.

Change-Id: I1e587ecdad5abff47d78362394cc0ecdb1ecd4c4

src/storage/Integrity.cpp
src/storage/Integrity.h

index 82e8f5a..5dfa624 100644 (file)
@@ -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 */
index d06eada..2917fb3 100644 (file)
@@ -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;