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 <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Scott Graham 2018-02-15 22:12:59 -08:00 committed by Commit Bot
parent 0429216f59
commit f38af628c9
2 changed files with 13 additions and 5 deletions

View File

@ -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.

View File

@ -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();