Commit 329c5bc2 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Use base::DeletePathRecursively() in more places.

Replace base::DeleteFile(path, true) with
base::DeletePathRecursively(path).

Bug: 1009837
Change-Id: Ida6763a208505b936f35a8d743ee0a147fd0a1bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276758Reviewed-by: default avatarJeroen Dhollander <jeroendh@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785986}
parent 87999a20
......@@ -407,12 +407,11 @@ void SnapshotManager::DeleteSnapshotDataForProfile(
// regardless of |delete_begin|, otherwise deletes the required files from
// the snapshot if it was created after |delete_begin|.
if (delete_all) {
base::DeleteFile(profile_absolute_path, /*recursive=*/true);
base::DeletePathRecursively(profile_absolute_path);
} else if (delete_begin <= file_info.creation_time &&
base::PathExists(profile_absolute_path)) {
for (const auto& filename : files_to_delete) {
base::DeleteFile(profile_absolute_path.Append(filename),
/*recursive=*/true);
base::DeletePathRecursively(profile_absolute_path.Append(filename));
}
// Non recursive deletion will fail if the directory is not empty. In this
// case we only want to delete the directory if it is empty.
......
......@@ -51,7 +51,7 @@ bool Run(base::CommandLine command_line, int* exit_code) {
} // namespace
void Clean() {
EXPECT_TRUE(base::DeleteFile(GetProductPath(), true));
EXPECT_TRUE(base::DeletePathRecursively(GetProductPath()));
EXPECT_TRUE(Launchd::GetInstance()->DeletePlist(
Launchd::User, Launchd::Agent, updater::CopyAdministrationLaunchDName()));
EXPECT_TRUE(Launchd::GetInstance()->DeletePlist(
......
......@@ -68,7 +68,7 @@ void Clean() {
// TODO(crbug.com/1062288): Delete the COM service items.
// TODO(crbug.com/1062288): Delete the COM interfaces.
// TODO(crbug.com/1062288): Delete the Wake task.
EXPECT_TRUE(base::DeleteFile(GetProductPath(), true));
EXPECT_TRUE(base::DeletePathRecursively(GetProductPath()));
}
void ExpectClean() {
......
......@@ -206,7 +206,7 @@ TEST_F(SynchronizedMinidumpManagerTest, FilePathsAreCorrect) {
TEST_F(SynchronizedMinidumpManagerTest, AcquireLockOnNonExistentDirectory) {
// The directory was created in SetUp(). Delete it and its contents.
ASSERT_TRUE(base::DeleteFile(minidump_dir_, true));
ASSERT_TRUE(base::DeletePathRecursively(minidump_dir_));
ASSERT_FALSE(base::PathExists(minidump_dir_));
SynchronizedMinidumpManagerSimple manager;
......
......@@ -68,7 +68,7 @@ bool FileProviderImpl::WriteSecureFile(const std::string& path,
}
void FileProviderImpl::CleanAssistantData() {
base::DeleteFile(root_path_, true);
base::DeletePathRecursively(root_path_);
}
bool FileProviderImpl::GetResource(uint16_t resource_id, std::string* out) {
......
......@@ -36,11 +36,11 @@ base::FilePath MetricKitReportDirectory() {
class MetricKitSubscriberTest : public PlatformTest {
public:
MetricKitSubscriberTest() {
base::DeleteFile(MetricKitReportDirectory(), true);
base::DeletePathRecursively(MetricKitReportDirectory());
}
~MetricKitSubscriberTest() override {
base::DeleteFile(MetricKitReportDirectory(), true);
base::DeletePathRecursively(MetricKitReportDirectory());
}
private:
......
......@@ -24,7 +24,7 @@ namespace {
void DeleteTempDownloadsDirectorySync() {
base::FilePath downloads_directory;
if (GetTempDownloadsDirectory(&downloads_directory)) {
DeleteFile(downloads_directory, /*recursive=*/true);
DeletePathRecursively(downloads_directory);
}
}
} // namespace
......
......@@ -353,7 +353,7 @@ leveldb::Status DeleteDB(const base::FilePath& db_path,
// TODO(cmumford): To be fully safe this implementation should acquire a lock
// as there is some daylight in between DestroyDB and DeleteFile.
if (!base::DeleteFile(db_path, true)) {
if (!base::DeletePathRecursively(db_path)) {
// Only delete the directory when when DestroyDB is successful. This is
// because DestroyDB checks for database locks, and will fail if in use.
return leveldb::Status::IOError(db_path.AsUTF8Unsafe(), "Error deleting");
......
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