Skip errored directory on file system visitor 65/73965/1
authorKyungwook Tak <k.tak@samsung.com>
Fri, 10 Jun 2016 07:57:14 +0000 (16:57 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Fri, 10 Jun 2016 07:58:25 +0000 (16:58 +0900)
Silently skip unable to read directory stream to reduce side-effect to
whole other directories.

Change-Id: Ied216e0efcb0598251f5f7fad8d7f9abdabd17b6
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/file-system.cpp

index 2c37315..16be24d 100644 (file)
@@ -274,8 +274,20 @@ FsVisitor::~FsVisitor()
 FilePtr FsVisitor::next()
 {
        struct dirent *result = nullptr;
-       while (readdir_r(this->m_dirptr.get(), this->m_entryBuf, &result) == 0) {
-               if (result == nullptr) { // end of dir stream
+       while (true) {
+               bool isDone = false;
+
+               if (readdir_r(this->m_dirptr.get(), this->m_entryBuf, &result) != 0) {
+                       ERROR("readdir_r error on dir: " << this->m_dirs.front() <<
+                                 " with errno: " << errno << ". Silently ignore this error & dir stream"
+                                 " to reduce side-effect of traversing all the other file systems.");
+                       isDone = true;
+               } else if (result == nullptr) {
+                       DEBUG("End of stream of dir: " << this->m_dirs.front());
+                       isDone = true;
+               }
+
+               if (isDone) {
                        this->m_dirs.pop();
                        while (!this->m_dirs.empty() &&
                                        !(this->m_dirptr = openDir(this->m_dirs.front())))