Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

FileSize failure HRESULT lost in DetectPackagePayloadsCached #4288

Closed
wixbot opened this Issue Jan 21, 2014 · 3 comments

Comments

Projects
None yet
2 participants
Collaborator

wixbot commented Jan 21, 2014

In core.cpp the function DetectPackagePayloadsCached has this code:

hr = FileSize(sczPayloadCachePath, &llSize);
if (SUCCEEDED(hr) && static_cast<DWORD64>(llSize) == pPackagePayload->pPayload->qwFileSize)
{
    pPackagePayload->fCached = TRUE;
}
else
{
    if (static_cast<DWORD64>(llSize) != pPackagePayload->pPayload->qwFileSize)
    {
        hr = HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT);
    }

    LogId(REPORT_STANDARD, MSG_DETECT_PACKAGE_NOT_FULLY_CACHED, pPackage->sczId, pPackagePayload->pPayload->sczKey, hr);

    cache = BURN_CACHE_STATE_PARTIAL; // found a payload that was not cached so we are partial.
    hr = S_OK;
}

If FileSize returns a error then it also returns file size 0. Thus the comparison at the start of the else will overwrite the return code with the generic ERROR_FILE_CORRUPT. This does not allow postmortem debugging based on the log file. Better would be to retain the HRESULT from FileSize and present that value in the log. I'd suggest modifying the code as follows:

hr = FileSize(sczPayloadCachePath, &llSize);
if (SUCCEEDED(hr) && static_cast<DWORD64>(llSize) == pPackagePayload->pPayload->qwFileSize)
{
    pPackagePayload->fCached = TRUE;
}
else
{
    if (SUCCEEDED(hr) && static_cast<DWORD64>(llSize) != pPackagePayload->pPayload->qwFileSize)
    {
        hr = HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT);
    }

    LogId(REPORT_STANDARD, MSG_DETECT_PACKAGE_NOT_FULLY_CACHED, pPackage->sczId, pPackagePayload->pPayload->sczKey, hr);

    cache = BURN_CACHE_STATE_PARTIAL; // found a payload that was not cached so we are partial.
    hr = S_OK;
}

The new test for SUCCEEDED(hr) means that the generic error code will only be returned if the actual file size differs from the stored value.

Originally opened by bernie.vachon

Collaborator

wixbot commented Jan 23, 2014

Originally changed by barnson
AssignedTo set to robmen
Release changed from v3.8 to v3.9

Collaborator

wixbot commented May 27, 2014

Fixed by https://github.com/wixtoolset/wix3/pull/47

Originally posted by robmen

Collaborator

wixbot commented May 28, 2014

Fixed in next build.

Originally posted by robmen
Resolution set to fixed
Status changed from Open to Resolved

@wixbot wixbot added bug burn labels Dec 20, 2015

@wixbot wixbot added this to the v3.9 milestone Dec 20, 2015

@wixbot wixbot closed this Dec 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment