Commit 074906f9 authored by mek's avatar mek Committed by Commit bot

Fix crash in DirectoryImpl::Flush()

BUG=None

Review-Url: https://codereview.chromium.org/2604843002
Cr-Commit-Position: refs/heads/master@{#440858}
parent 0f99a7ab
...@@ -224,7 +224,8 @@ void DirectoryImpl::IsWritable(const std::string& raw_path, ...@@ -224,7 +224,8 @@ void DirectoryImpl::IsWritable(const std::string& raw_path,
} }
void DirectoryImpl::Flush(const FlushCallback& callback) { void DirectoryImpl::Flush(const FlushCallback& callback) {
base::File file(directory_path_, base::File::FLAG_READ); base::File file(directory_path_,
base::File::FLAG_OPEN | base::File::FLAG_READ);
if (!file.IsValid()) { if (!file.IsValid()) {
callback.Run(GetError(file)); callback.Run(GetError(file));
return; return;
......
...@@ -276,6 +276,18 @@ TEST_F(DirectoryImplTest, CantWriteFileOnADirectory) { ...@@ -276,6 +276,18 @@ TEST_F(DirectoryImplTest, CantWriteFileOnADirectory) {
} }
} }
TEST_F(DirectoryImplTest, Flush) {
mojom::DirectoryPtr directory;
GetTemporaryRoot(&directory);
mojom::FileError error;
{
bool handled = directory->Flush(&error);
ASSERT_TRUE(handled);
EXPECT_EQ(mojom::FileError::OK, error);
}
}
// TODO(vtl): Test delete flags. // TODO(vtl): Test delete flags.
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment