Commit 1b0b1cf2 authored by Min Qin's avatar Min Qin Committed by Chromium LUCI CQ

Fix a condition when finding duplicate completed download

BUG=1157734

Change-Id: I419951b1c9880054f98d59eddaa681f02bb0359e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586223Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836294}
parent b67127ab
......@@ -257,7 +257,7 @@ bool ShouldSkipLoadingDownload(const history::DownloadRow& row,
return false;
}
if (row.state != DownloadState::COMPLETE && row.target_path.empty())
if (row.state != DownloadState::COMPLETE || row.target_path.empty())
return false;
const std::string file_path = row.target_path.AsUTF8Unsafe();
if (file_path.empty())
......
......@@ -926,7 +926,7 @@ TEST_F(DownloadHistoryTest,
download::features::kDeleteOverwrittenDownloads, params);
// Load a download from history, create the item, OnDownloadCreated,
// OnDownloadUpdated, OnDownloadRemoved.
history::DownloadRow row0, row1;
history::DownloadRow row0, row1, row2;
InitDownloadRow(FILE_PATH_LITERAL("/foo/bar.pdf"),
"http://example.com/bar.pdf",
"http://example.com/referrer.html",
......@@ -935,16 +935,23 @@ TEST_F(DownloadHistoryTest,
"http://example2.com/bar.pdf",
"http://example.com/referrer1.html",
download::DownloadItem::COMPLETE, &row1);
InitBasicItem(FILE_PATH_LITERAL("/foo/bar.pdf"),
"http://example2.com/bar.pdf",
"http://example.com/referrer1.html",
download::DownloadItem::IN_PROGRESS, &row2);
{
std::vector<CreateDownloadHistoryEntry> rows = {
CreateDownloadHistoryEntry(row0, LoadDownloadRowResult::kSkipCreation),
CreateDownloadHistoryEntry(row1)};
CreateDownloadHistoryEntry(row1), CreateDownloadHistoryEntry(row2)};
CreateDownloadHistory(std::move(rows));
ExpectNoDownloadCreated();
}
EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0)));
EXPECT_TRUE(DownloadHistory::IsPersisted(&item(1)));
EXPECT_EQ(item(0).GetState(), download::DownloadItem::COMPLETE);
EXPECT_EQ(item(1).GetState(), download::DownloadItem::IN_PROGRESS);
}
// Tests that overwritten download is not removed from history DB before the
......
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