Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ The PowerShell module now automatically uses `GH_TOKEN` or `GITHUB_TOKEN` enviro

## Bug Fixes

<!-- Nothing yet! -->
* DSC export now correctly exports WinGet Admin Settings
19 changes: 18 additions & 1 deletion src/AppInstallerCommonCore/AdminSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,22 @@ namespace AppInstaller::Settings

void AdminSettingsInternal::LoadAdminSettings()
{
auto stream = m_settingStream.Get();
std::unique_ptr<std::istream> stream;
try
{
stream = m_settingStream.Get();
}
catch (const std::exception& e)
{
AICLI_LOG(Core, Error, << "Failed to read admin settings: " << e.what() << ". Falling back to default values.");
return;
}
catch (...)
{
AICLI_LOG(Core, Error, << "Failed to read admin settings due to unknown exception. Falling back to default values.");
return;
}

if (!stream)
{
AICLI_LOG(Core, Verbose, << "Admin settings was not found");
Expand Down Expand Up @@ -223,6 +238,8 @@ namespace AppInstaller::Settings
{
m_settingValues.DefaultProxy.emplace(std::move(defaultProxy));
}

AICLI_LOG(Core, Verbose, << "Admin settings loaded successfully");
}

bool AdminSettingsInternal::SaveAdminSettings()
Expand Down
19 changes: 16 additions & 3 deletions src/AppInstallerCommonCore/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,19 @@ namespace AppInstaller::Settings
return result;
}

void SetVerificationData(VerificationData data)
bool SetVerificationData(VerificationData data)
{
YAML::Emitter out;
out << YAML::BeginMap;
out << YAML::Key << NodeName_Sha256 << YAML::Value << SHA256::ConvertToString(data.Hash);
out << YAML::EndMap;

m_secure.Set(out.str());
bool result = m_secure.Set(out.str());
if (!result)
{
AICLI_LOG(Core, Warning, << "Failed to write verification data for '" << m_name << "'");
}
return result;
}

public:
Expand Down Expand Up @@ -338,7 +343,15 @@ namespace AppInstaller::Settings
VerificationData verData;
verData.Hash = m_hash.value();

SetVerificationData(verData);
if (!SetVerificationData(verData))
{
AICLI_LOG(Core, Error, << "Failed to write verification data for '" << m_name << "'. Reverting setting write to maintain consistency.");
AICLI_LOG(Core, Warning, << "This failure may be caused by insufficient permissions or disk space issues");
// Verification data write failed, so we need to revert the main write
// to maintain consistency
Remove();
return false;
}
}

return exchangeResult;
Expand Down
Loading