summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorbradnelson <bradnelson@google.com>2015-02-04 10:06:19 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-04 18:07:18 +0000
commitc27b19192a297c1b81da98e728305d4a5009a081 (patch)
tree082b044747d8e333c676424d151d5aa22909bd0f /native_client_sdk
parent174f0fb391c2504354548571d83d79c93ce1c380 (diff)
downloadchromium_src-c27b19192a297c1b81da98e728305d4a5009a081.zip
chromium_src-c27b19192a297c1b81da98e728305d4a5009a081.tar.gz
chromium_src-c27b19192a297c1b81da98e728305d4a5009a081.tar.bz2
Fixing bad error return code in html5fs remove/unlink/rmdir.
Creating a FileRef does not check if the file exists or not. We had assumed that if a FileRef could be created that the file or directory in question exists. Instead look at the result code from Query and possibly return ENOENT if it turns out the file or diretory does not exist. BUG=None TEST=nacl_io_tests R=sbc@chromium.org Review URL: https://codereview.chromium.org/899003002 Cr-Commit-Position: refs/heads/master@{#314582}
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc3
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc3
2 files changed, 6 insertions, 0 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc
index f744750..bb6b9cc 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc
@@ -155,6 +155,9 @@ Error Html5Fs::RemoveInternal(const Path& path, int remove_type) {
int32_t query_result = file_ref_iface_->Query(
fileref_resource.pp_resource(), &file_info, PP_BlockUntilComplete());
if (query_result != PP_OK) {
+ if (query_result == PP_ERROR_FILENOTFOUND) {
+ return ENOENT;
+ }
LOG_ERROR("Error querying file type");
return EINVAL;
}
diff --git a/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
index 3cb8d16..abffa13 100644
--- a/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc
@@ -198,6 +198,7 @@ TEST_F(Html5FsTest, Remove) {
ASSERT_TRUE(fs->Exists(kPath));
ASSERT_EQ(0, fs->Remove(path));
EXPECT_FALSE(fs->Exists(kPath));
+ ASSERT_EQ(ENOENT, fs->Remove(path));
}
TEST_F(Html5FsTest, Unlink) {
@@ -213,6 +214,7 @@ TEST_F(Html5FsTest, Unlink) {
ASSERT_EQ(EISDIR, fs->Unlink(Path("/dir")));
EXPECT_FALSE(fs->Exists("/file"));
EXPECT_TRUE(fs->Exists("/dir"));
+ ASSERT_EQ(ENOENT, fs->Unlink(Path("/file")));
}
TEST_F(Html5FsTest, Rmdir) {
@@ -226,6 +228,7 @@ TEST_F(Html5FsTest, Rmdir) {
EXPECT_EQ(0, fs->Rmdir(Path("/dir")));
EXPECT_FALSE(fs->Exists("/dir"));
EXPECT_TRUE(fs->Exists("/file"));
+ EXPECT_EQ(ENOENT, fs->Rmdir(Path("/dir")));
}
TEST_F(Html5FsTest, Rename) {