Skip to content

Commit

Permalink
DO SDK: Handle downlevel OS set_property failure (#117)
Browse files Browse the repository at this point in the history
* Temporary workaround for Chromium/Edge running on 19H1 or lower Windows versions.
* CV and integrity check info is not mandatory for this use case, ok to ignore errors. Chromium/Edge performs its own hash check after download is complete.
  • Loading branch information
shishirb-MSFT authored Apr 21, 2022
1 parent 7027c2b commit 2a6ac35
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion sdk-cpp/src/do_download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ std::error_code download::download_url_to_path_nothrow(const std::string& uri, c
return oneShotDownload->start_and_wait_until_completion_nothrow(isCancelled, timeOut);
}

static std::error_code g_TryOverrideDownlevelOsSetPropertyError(download_property prop, std::error_code ec)
{
// Temporary backward-compatibility for Chromium/Edge.
// These properties were not supported in IDODownload interface until build 19041.
if ((ec.value() == static_cast<int>(errc::do_e_unknown_property_id)) &&
((prop == download_property::correlation_vector) || (prop == download_property::integrity_check_info)))
{
return DO_OK;
}
else
{
return ec;
}
}

std::error_code download::set_property_nothrow(download_property prop, const download_property_value& val) noexcept
{
if (prop == download_property::callback_interface)
Expand All @@ -228,7 +243,8 @@ std::error_code download::set_property_nothrow(download_property prop, const dow
}
else
{
return _download->SetProperty(prop, val);
auto ec = _download->SetProperty(prop, val);
return g_TryOverrideDownlevelOsSetPropertyError(prop, ec);
}
}

Expand Down

0 comments on commit 2a6ac35

Please sign in to comment.