From b1db67d895aecb2dcee0bda287e5c012b3345bfd Mon Sep 17 00:00:00 2001
From: =?utf8?q?Piotr=20Kosko/Native/Web=20API=20=28PLT=29=20/SRPOL/Profess?=
=?utf8?q?ional/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?=
Date: Mon, 8 Apr 2019 10:18:05 +0200
Subject: [PATCH] [Filesystem] listFiles method of File ignores files without
access
[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 | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/filesystem/filesystem_instance.cc b/src/filesystem/filesystem_instance.cc
index fbd555fd..6c2367fd 100644
--- a/src/filesystem/filesystem_instance.cc
+++ b/src/filesystem/filesystem_instance.cc
@@ -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::type>(stat.error));
+ }
}
ReportSuccess(result, obj);
Instance::PostMessage(this, response.serialize().c_str());
--
2.34.1