summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
authortzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 06:07:44 +0000
committertzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 06:07:44 +0000
commit9dfdc0e30992e5b43ecc02dba9a49396439901d7 (patch)
treeda6b82f7095347e43dcfbb6ba1a88360cdf96ef8 /webkit/fileapi
parent000b534024e7abd56628af5522d6e136a0fe2375 (diff)
downloadchromium_src-9dfdc0e30992e5b43ecc02dba9a49396439901d7.zip
chromium_src-9dfdc0e30992e5b43ecc02dba9a49396439901d7.tar.gz
chromium_src-9dfdc0e30992e5b43ecc02dba9a49396439901d7.tar.bz2
Don't abort reading directory when a backing file lost.
BUG=91328 TEST='ObfuscatedFileSystemFileUtilTest.*' Review URL: http://codereview.chromium.org/7806007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/obfuscated_file_system_file_util.cc7
-rw-r--r--webkit/fileapi/obfuscated_file_system_file_util_unittest.cc35
2 files changed, 40 insertions, 2 deletions
diff --git a/webkit/fileapi/obfuscated_file_system_file_util.cc b/webkit/fileapi/obfuscated_file_system_file_util.cc
index 11fae60..f07adfa 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util.cc
+++ b/webkit/fileapi/obfuscated_file_system_file_util.cc
@@ -278,8 +278,11 @@ PlatformFileError ObfuscatedFileSystemFileUtil::ReadDirectory(
if (GetFileInfoInternal(db, context, *iter,
&file_info, &platform_file_info, &file_path) !=
base::PLATFORM_FILE_OK) {
- NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ LOG(WARNING) << "Lost a backing file.";
+ // TODO(tzik): We found a file entry in directory database without
+ // backing file here. Track the inconsistency and remove the database
+ // entry if we can't recover it.
+ continue;
}
base::FileUtilProxy::Entry entry;
diff --git a/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
index 051d37c..879338f 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
+++ b/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
@@ -1412,3 +1412,38 @@ TEST_F(ObfuscatedFileSystemFileUtilTest, TestInconsistency) {
EXPECT_EQ(0, file_info.size);
EXPECT_TRUE(base::ClosePlatformFile(file));
}
+
+TEST_F(ObfuscatedFileSystemFileUtilTest, TestIncompleteDirectoryReading) {
+ const FilePath kPath[] = {
+ FilePath().AppendASCII("foo"),
+ FilePath().AppendASCII("bar"),
+ FilePath().AppendASCII("baz")
+ };
+ scoped_ptr<FileSystemOperationContext> context;
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) {
+ bool created = false;
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->EnsureFileExists(context.get(), kPath[i], &created));
+ EXPECT_TRUE(created);
+ }
+
+ context.reset(NewContext(NULL));
+ std::vector<base::FileUtilProxy::Entry> entries;
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->ReadDirectory(context.get(), FilePath(), &entries));
+ EXPECT_EQ(3u, entries.size());
+
+ context.reset(NewContext(NULL));
+ FilePath local_path;
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->GetLocalFilePath(context.get(), kPath[0], &local_path));
+ EXPECT_TRUE(file_util::Delete(local_path, false));
+
+ context.reset(NewContext(NULL));
+ entries.clear();
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->ReadDirectory(context.get(), FilePath(), &entries));
+ EXPECT_EQ(ARRAYSIZE_UNSAFE(kPath) - 1, entries.size());
+}