Skip to content

Commit 484a898

Browse files
committed
Revert to WIL logging
1 parent 9c47b70 commit 484a898

1 file changed

Lines changed: 6 additions & 35 deletions

File tree

src/AppInstallerCommonCore/Downloader.cpp

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,8 @@ namespace AppInstaller::Utility
495495

496496
THROW_IF_FAILED(hr);
497497

498-
auto hrRemove = zoneIdentifier->Remove();
499-
if (FAILED(hrRemove))
500-
{
501-
AICLI_LOG(Core, Error, << "IZoneIdentifier::Remove failed. Result: " << hrRemove);
502-
THROW_IF_FAILED(hrRemove);
503-
}
504-
505-
auto hrSave = persistFile->Save(NULL, TRUE);
506-
if (FAILED(hrSave))
507-
{
508-
AICLI_LOG(Core, Error, << "IPersistFile::Save failed after removing motw. Result: " << hrSave);
509-
THROW_IF_FAILED(hrSave);
510-
}
498+
THROW_IF_FAILED(zoneIdentifier->Remove());
499+
THROW_IF_FAILED(persistFile->Save(NULL, TRUE));
511500

512501
AICLI_LOG(Core, Info, << "Finished removing motw");
513502
}
@@ -527,26 +516,9 @@ namespace AppInstaller::Utility
527516
auto updateMotw = [&]() -> HRESULT
528517
{
529518
Microsoft::WRL::ComPtr<IAttachmentExecute> attachmentExecute;
530-
auto hrCreate = CoCreateInstance(CLSID_AttachmentServices, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&attachmentExecute));
531-
if (FAILED(hrCreate))
532-
{
533-
AICLI_LOG(Core, Error, << "CoCreateInstance(CLSID_AttachmentServices) failed. Result: " << hrCreate);
534-
return hrCreate;
535-
}
536-
537-
auto hrSetLocalPath = attachmentExecute->SetLocalPath(filePath.c_str());
538-
if (FAILED(hrSetLocalPath))
539-
{
540-
AICLI_LOG(Core, Error, << "IAttachmentExecute::SetLocalPath failed for path: " << filePath << " Result: " << hrSetLocalPath);
541-
return hrSetLocalPath;
542-
}
543-
544-
auto hrSetSource = attachmentExecute->SetSource(Utility::ConvertToUTF16(source).c_str());
545-
if (FAILED(hrSetSource))
546-
{
547-
AICLI_LOG(Core, Error, << "IAttachmentExecute::SetSource failed for source: " << source << " Result: " << hrSetSource);
548-
return hrSetSource;
549-
}
519+
RETURN_IF_FAILED(CoCreateInstance(CLSID_AttachmentServices, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&attachmentExecute)));
520+
RETURN_IF_FAILED(attachmentExecute->SetLocalPath(filePath.c_str()));
521+
RETURN_IF_FAILED(attachmentExecute->SetSource(Utility::ConvertToUTF16(source).c_str()));
550522

551523
// IAttachmentExecute::Save() expects the local file to be clean (i.e. it won't clear existing motw if it thinks the source url is trusted).
552524
// If removal fails for any reason, log a warning and proceed — a removal failure should not abort the security check.
@@ -579,10 +551,9 @@ namespace AppInstaller::Utility
579551
{
580552
try
581553
{
582-
hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
554+
hr = LOG_IF_FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED));
583555
if (FAILED(hr))
584556
{
585-
AICLI_LOG(Core, Error, << "CoInitializeEx failed in IAttachmentExecute thread. Result: " << hr);
586557
return;
587558
}
588559

0 commit comments

Comments
 (0)