From cddee79d14036a337dd2d9fb7882fb1da2fe42eb Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Tue, 25 Apr 2023 11:48:37 +0100 Subject: Don't log error when deleting a file that doesn't exist. Similar to commit 9b2bddc732b8a09b7091f983ee8161f1db277cae, but for another method. Bug: 261431149 Test: - 1. Add a "sleep" between artd invoking dex2oat and moving the files. 2. Install an app. 3. Run "pm compile" on the app. 4. While "pm compile" is on "sleep", uninstall the app. 5. See no message like "Failed to remove file '...': Success". Ignore-AOSP-First: ART Services Change-Id: I274457b892bcb2426fc5e01470212597f63c8323 --- artd/file_utils.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'artd') diff --git a/artd/file_utils.cc b/artd/file_utils.cc index 0ce782a7e9..fb55dec5d5 100644 --- a/artd/file_utils.cc +++ b/artd/file_utils.cc @@ -50,10 +50,9 @@ using ::fmt::literals::operator""_format; // NOLINT void UnlinkIfExists(const std::string& path) { std::error_code ec; - if (!std::filesystem::remove(path, ec)) { - if (ec.value() != ENOENT) { - LOG(WARNING) << "Failed to remove file '{}': {}"_format(path, ec.message()); - } + std::filesystem::remove(path, ec); + if (ec) { + LOG(WARNING) << "Failed to remove file '{}': {}"_format(path, ec.message()); } } -- cgit v1.2.3-59-g8ed1b