From 664c3b563a6887dcd2ff788ad8fba5530a19e14c Mon Sep 17 00:00:00 2001 From: Rahman Abber Tahir Date: Mon, 20 Nov 2023 18:35:18 +0100 Subject: [PATCH] added comments and function description. Signed-off-by: Rahman Abber Tahir --- src/libLocalDescriptorCache/DescDbProxy.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libLocalDescriptorCache/DescDbProxy.cpp b/src/libLocalDescriptorCache/DescDbProxy.cpp index 9cb55e2..417928f 100644 --- a/src/libLocalDescriptorCache/DescDbProxy.cpp +++ b/src/libLocalDescriptorCache/DescDbProxy.cpp @@ -301,6 +301,7 @@ std::string DescDbProxy::prepareCacheFile() return dbFilePath; } +/// returns false if file was found but could not be parsed. true otherwise. static bool getDbFileFromCacheFile(const std::string& cacheFilePath, localDescDb::DescriptorDb& file) { // Import .prot file @@ -328,8 +329,12 @@ void DescDbProxy::getDescriptors(const std::string &f_hostAddress) std::string cacheFilePath = prepareCacheFile(); if( getDbFileFromCacheFile(cacheFilePath, dbFile) == false ) { - localDescDb::DescriptorDb newDbFile; //new file to ensure there are no side-effects from last parsing failure. - std::filesystem::remove(cacheFilePath); //remove cache file if failed and try again. + // Parsing the cache file failed. re-instantiating the cache: + // remove cache file if failed and try again. + std::filesystem::remove(cacheFilePath); + + // new file to ensure there are no side-effects from last parsing failure. + localDescDb::DescriptorDb newDbFile; if( getDbFileFromCacheFile(cacheFilePath, newDbFile) == false ) {