Commit 9c7aeb26 authored by asanka@chromium.org's avatar asanka@chromium.org

Avoid trying to delete a non-existent file.

BUG=368455

Review URL: https://codereview.chromium.org/296933016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272726 0039d316-1c4b-4281-b951-d872f2087c98
parent 82952dfb
......@@ -185,9 +185,10 @@ void BaseFile::Cancel() {
if (!full_path_.empty()) {
bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_DELETED);
base::DeleteFile(full_path_, false);
}
Detach();
}
void BaseFile::Finish() {
......
......@@ -619,4 +619,21 @@ TEST_F(BaseFileTest, CreatedInDefaultDirectory) {
base_file_->Finish();
}
TEST_F(BaseFileTest, NoDoubleDeleteAfterCancel) {
ASSERT_TRUE(InitializeFile());
base::FilePath full_path = base_file_->full_path();
ASSERT_FALSE(full_path.empty());
ASSERT_TRUE(base::PathExists(full_path));
base_file_->Cancel();
ASSERT_FALSE(base::PathExists(full_path));
const char kData[] = "hello";
const int kDataLength = static_cast<int>(arraysize(kData) - 1);
ASSERT_EQ(kDataLength, base::WriteFile(full_path, kData, kDataLength));
// The file that we created here should stick around when the BaseFile is
// destroyed during TearDown.
expect_file_survives_ = true;
}
} // namespace content
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