From f38af628c9dc8bef6cf34cd69037c67092e13649 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Thu, 15 Feb 2018 22:12:59 -0800 Subject: [PATCH] fuchsia: Don't fail rename if source == dest Fuchsia errors out in rename() when source == dest. I believe this is incorrect according to http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html, but it's also relatively easy to work around in our code, and this fixes CrashReportDatabaseTest.RequestUpload. This is ZX-1729 upstream. Bug: crashpad:196 Change-Id: I27473183b04484e146a7bd9e87e60be3aeff1932 Reviewed-on: https://chromium-review.googlesource.com/923708 Reviewed-by: Mark Mentovai Commit-Queue: Scott Graham --- client/crash_report_database_test.cc | 10 +++++----- util/file/filesystem_posix.cc | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/crash_report_database_test.cc b/client/crash_report_database_test.cc index 7760b4a1..55bcf3cd 100644 --- a/client/crash_report_database_test.cc +++ b/client/crash_report_database_test.cc @@ -628,21 +628,21 @@ TEST_F(CrashReportDatabaseTest, RequestUpload) { ASSERT_EQ(pending_reports.size(), 2u); // Check individual reports. - const CrashReportDatabase::Report* expicitly_requested_report; + const CrashReportDatabase::Report* explicitly_requested_report; const CrashReportDatabase::Report* pending_report; if (pending_reports[0].uuid == report_0_uuid) { pending_report = &pending_reports[0]; - expicitly_requested_report = &pending_reports[1]; + explicitly_requested_report = &pending_reports[1]; } else { pending_report = &pending_reports[1]; - expicitly_requested_report = &pending_reports[0]; + explicitly_requested_report = &pending_reports[0]; } EXPECT_EQ(pending_report->uuid, report_0_uuid); EXPECT_FALSE(pending_report->upload_explicitly_requested); - EXPECT_EQ(expicitly_requested_report->uuid, report_1_uuid); - EXPECT_TRUE(expicitly_requested_report->upload_explicitly_requested); + EXPECT_EQ(explicitly_requested_report->uuid, report_1_uuid); + EXPECT_TRUE(explicitly_requested_report->upload_explicitly_requested); // Explicitly requested reports will not have upload_explicitly_requested bit // after getting skipped. diff --git a/util/file/filesystem_posix.cc b/util/file/filesystem_posix.cc index b1f19f62..c2234dae 100644 --- a/util/file/filesystem_posix.cc +++ b/util/file/filesystem_posix.cc @@ -65,6 +65,14 @@ bool LoggingCreateDirectory(const base::FilePath& path, bool MoveFileOrDirectory(const base::FilePath& source, const base::FilePath& dest) { +#if defined(OS_FUCHSIA) + // Fuchsia fails and sets errno to EINVAL if source and dest are the same. + // Upstream bug is ZX-1729. + if (!source.empty() && source == dest) { + return true; + } +#endif // OS_FUCHSIA + if (rename(source.value().c_str(), dest.value().c_str()) != 0) { PLOG(ERROR) << "rename " << source.value().c_str() << ", " << dest.value().c_str();