[Filesystem] listFiles method of File ignores files without access 71/203071/1
authorPiotr Kosko/Native/Web API (PLT) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Mon, 8 Apr 2019 08:18:05 +0000 (10:18 +0200)
committerPiotr Kosko/Native/Web API (PLT) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Tue, 9 Apr 2019 10:01:11 +0000 (12:01 +0200)
[Bug] Files with invalid SMACK labels (not allowed to be accessed by app)
caused exception about missing member ("location is required argument").

Fix ignores the files that cannot be accessed.

[Verification] Manually checked with Chrome console and trying to list files
with invalid SMACK label. Files are being ignored.
100% passrate for filesystem module.

Change-Id: I48ed83ebbba5d0c6cfa0e597f083a7a1abce17fa

src/filesystem/filesystem_instance.cc

index fbd555fdd5fe0f816fee8dd8153a239a325680ab..6c2367fdfa7508e2ec0ab76c483dd1df6aed21c8 100644 (file)
@@ -657,7 +657,13 @@ void FilesystemInstance::ReadDir(const picojson::value& args, picojson::object&
     obj["callbackId"] = picojson::value(callback_id);
     for (auto path : paths) {
       FilesystemStat stat = FilesystemStat::getStat(path);
-      statPaths.push_back(stat.toJSON());
+
+      if (FilesystemError::None == stat.error) {
+        statPaths.push_back(stat.toJSON());
+      } else {
+        LoggerW("File stat for path: %s failed with error: %d. Ignoring this entry.", path.c_str(),
+                static_cast<std::underlying_type<FilesystemError>::type>(stat.error));
+      }
     }
     ReportSuccess(result, obj);
     Instance::PostMessage(this, response.serialize().c_str());