summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyungwook Tak <k.tak@samsung.com>2016-07-05 15:15:16 +0900
committerKyungwook Tak <k.tak@samsung.com>2016-07-05 15:18:37 +0900
commit0ce2e2fe413230f2498e402f7a3e29afc81d3354 (patch)
tree3ab8517ae0cbb3c00e789233ba5c79e17ff80955
parent759e0ddc95f143c0166c050989ff200e8c477a92 (diff)
downloadcsr-framework-0ce2e2fe413230f2498e402f7a3e29afc81d3354.tar.gz
csr-framework-0ce2e2fe413230f2498e402f7a3e29afc81d3354.tar.bz2
csr-framework-0ce2e2fe413230f2498e402f7a3e29afc81d3354.zip
Handle exception when open dir top dir in fs visitor
Change-Id: Ia9fc53a10ade30cfc64bf1c1ff861281c7d908d8 Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
-rw-r--r--src/framework/service/file-system.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/framework/service/file-system.cpp b/src/framework/service/file-system.cpp
index 80aa760..71a1528 100644
--- a/src/framework/service/file-system.cpp
+++ b/src/framework/service/file-system.cpp
@@ -246,8 +246,8 @@ FsVisitorPtr FsVisitor::create(TargetHandler &&targetHandler,
isBasedOnName, modifiedSince));
}
-FsVisitor::FsVisitor(TargetHandler &&targetHandler,
- const std::string &dirpath, bool isBasedOnName, time_t modifiedSince) :
+FsVisitor::FsVisitor(TargetHandler &&targetHandler, const std::string &dirpath,
+ bool isBasedOnName, time_t modifiedSince) :
m_targetHandler(std::move(targetHandler)), m_path(dirpath),
m_since(modifiedSince), m_isDone(true), m_isBasedOnName(isBasedOnName),
m_entryBuf(static_cast<struct dirent *>(::malloc(offsetof(struct dirent, d_name) + NAME_MAX + 1)))
@@ -293,7 +293,7 @@ void FsVisitor::run(const DirPtr &dirptr, const FilePtr &currentdir)
auto ndirptr = openDir(fullpath);
if (ndirptr == nullptr) {
- WARN("Failed to open dir: " << fullpath);
+ WARN("Failed to open dir: " << fullpath << " with errno: " << errno);
continue;
}
@@ -337,6 +337,20 @@ void FsVisitor::run(const DirPtr &dirptr, const FilePtr &currentdir)
void FsVisitor::run()
{
auto dirptr = openDir(this->m_path);
+
+ if (dirptr == nullptr) {
+ int err = errno;
+ WARN("Failed to open dir: " << this->m_path << " with errno: " << err <<
+ ". let's retry.");
+ dirptr = openDir(this->m_path);
+ if (dirptr == nullptr) {
+ err = errno;
+ WARN("Failed to open dir again: " << this->m_path << " with errno: " << err <<
+ ". let's skip.");
+ return;
+ }
+ }
+
auto currentdir = File::create(this->m_path, nullptr);
INFO("Visiting files start from dir: " << this->m_path);