Skip to content

Commit

Permalink
The fixes include
Browse files Browse the repository at this point in the history
1. removing the repair applicability check for MSIX/MSSTORE packages,
2. updating the repair execution logic to obtain the installer type from the Installer context,
3. honoring the StorePolicy check before store repair operation, |
4. displaying installation disclaimers and prompts for Installer type packages, and
5. revising the MSIX repair registration logic to show progress value.
  • Loading branch information
Madhusudhan-MSFT committed Feb 2, 2024
1 parent 7adf8da commit 7c94bd3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
55 changes: 33 additions & 22 deletions src/AppInstallerCLICore/Workflows/RepairFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Workflows/DownloadFlow.h"
#include "Workflows/ArchiveFlow.h"
#include "Workflows/InstallFlow.h"
#include "Workflows/PromptFlow.h"
#include "winget/ManifestCommon.h"
#include "AppInstallerDeployment.h"
#include "AppInstallerMsixInfo.h"
Expand Down Expand Up @@ -96,26 +97,34 @@ namespace AppInstaller::CLI::Workflow
const std::string installerType = context.Get<Execution::Data::InstalledPackageVersion>()->GetMetadata()[PackageVersionMetadata::InstalledType];
InstallerTypeEnum installerTypeEnum = ConvertToInstallerTypeEnum(installerType);

if (installerTypeEnum == InstallerTypeEnum::Burn
|| installerTypeEnum == InstallerTypeEnum::Exe
|| installerTypeEnum == InstallerTypeEnum::Inno
|| installerTypeEnum == InstallerTypeEnum::Nullsoft
|| installerTypeEnum == InstallerTypeEnum::Msi
|| installerTypeEnum == InstallerTypeEnum::Wix)
switch (installerTypeEnum)
{
IPackageVersion::Metadata packageMetadata = installedPackageVersion->GetMetadata();

auto noModifyItr = packageMetadata.find(PackageVersionMetadata::NoModify);
std::string noModifyARPFlag = noModifyItr != packageMetadata.end() ? noModifyItr->second : std::string();

auto noRepairItr = packageMetadata.find(PackageVersionMetadata::NoRepair);
std::string noRepairARPFlag = noRepairItr != packageMetadata.end() ? noRepairItr->second : std::string();

if (Utility::IsDwordFlagSet(noModifyARPFlag) || Utility::IsDwordFlagSet(noRepairARPFlag))
{
context.Reporter.Error() << Resource::String::RepairOperationNotSupported << std::endl;
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_REPAIR_NOT_SUPPORTED);
}
case InstallerTypeEnum::Burn:
case InstallerTypeEnum::Exe:
case InstallerTypeEnum::Inno:
case InstallerTypeEnum::Nullsoft:
case InstallerTypeEnum::Msi:
case InstallerTypeEnum::Wix:
{
IPackageVersion::Metadata packageMetadata = installedPackageVersion->GetMetadata();

auto noModifyItr = packageMetadata.find(PackageVersionMetadata::NoModify);
std::string noModifyARPFlag = noModifyItr != packageMetadata.end() ? noModifyItr->second : std::string();

auto noRepairItr = packageMetadata.find(PackageVersionMetadata::NoRepair);
std::string noRepairARPFlag = noRepairItr != packageMetadata.end() ? noRepairItr->second : std::string();

if (Utility::IsDwordFlagSet(noModifyARPFlag) || Utility::IsDwordFlagSet(noRepairARPFlag))
{
context.Reporter.Error() << Resource::String::RepairOperationNotSupported << std::endl;
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_REPAIR_NOT_SUPPORTED);
}
}
break;
case InstallerTypeEnum::Msix:
case InstallerTypeEnum::MSStore:
default:
return; // No check for these types
}

auto const& repairBehavior = context.Get<Execution::Data::Installer>()->RepairBehavior;
Expand All @@ -135,8 +144,8 @@ namespace AppInstaller::CLI::Workflow

void ExecuteRepair(Execution::Context& context)
{
const std::string installerType = context.Get<Execution::Data::InstalledPackageVersion>()->GetMetadata()[PackageVersionMetadata::InstalledType];
InstallerTypeEnum installerTypeEnum = ConvertToInstallerTypeEnum(installerType);
const auto& installer = context.Get<Execution::Data::Installer>();
InstallerTypeEnum installerTypeEnum = installer->EffectiveInstallerType();

Synchronization::CrossProcessInstallLock lock;

Expand All @@ -161,7 +170,6 @@ namespace AppInstaller::CLI::Workflow
case InstallerTypeEnum::Inno:
case InstallerTypeEnum::Nullsoft:
{
const auto& installer = context.Get<Execution::Data::Installer>();
const auto& repairBehavior = installer->RepairBehavior;

if (repairBehavior == RepairBehaviorEnum::Modify || repairBehavior == RepairBehaviorEnum::Uninstaller)
Expand Down Expand Up @@ -203,6 +211,7 @@ namespace AppInstaller::CLI::Workflow
case InstallerTypeEnum::MSStore:
{
context <<
EnsureStorePolicySatisfied <<
Workflow::MSStoreRepair;
}

Expand Down Expand Up @@ -271,6 +280,8 @@ namespace AppInstaller::CLI::Workflow
break;
case RepairBehaviorEnum::Installer:
context <<
Workflow::ShowInstallationDisclaimer <<
Workflow::ShowPromptsForSinglePackage(/* ensureAcceptance */ true) <<
Workflow::DownloadInstaller;

if (installerType == InstallerTypeEnum::Zip)
Expand Down
17 changes: 11 additions & 6 deletions src/AppInstallerCommonCore/Deployment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,18 @@ namespace AppInstaller::Deployment
std::string_view packageFamilyName,
IProgressCallback& callback)
{
size_t id = GetDeploymentOperationId();
AICLI_LOG(Core, Info, << "Starting RegisterPackageByFullNameAsync operation #" << id << ": " << packageFamilyName);
PartialPercentProgressCallback progress{ callback, 100 };

PackageManager packageManager;
winrt::hstring packageFamilyNameWide = Utility::ConvertToUTF16(packageFamilyName).c_str();
auto deployOperation = packageManager.RegisterPackageByFamilyNameAsync(packageFamilyNameWide, nullptr, DeploymentOptions::None, nullptr, nullptr);
progress.SetRange(0, 100);
{
size_t id = GetDeploymentOperationId();
AICLI_LOG(Core, Info, << "Starting RegisterPackageByFullNameAsync operation #" << id << ": " << packageFamilyName);

WaitForDeployment(deployOperation, id, callback);
PackageManager packageManager;
winrt::hstring packageFamilyNameWide = Utility::ConvertToUTF16(packageFamilyName).c_str();
auto deployOperation = packageManager.RegisterPackageByFamilyNameAsync(packageFamilyNameWide, nullptr, DeploymentOptions::None, nullptr, nullptr);

WaitForDeployment(deployOperation, id, callback);
}
}
}

1 comment on commit 7c94bd3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (7)

Contruct
Installimpl
ocale
omus
resuse
Shelle
skipt

Previously acknowledged words that are now absent bitspace Mta PFM testdata :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:Madhusudhan-MSFT/winget-cli.git repository
on the user/masudars/winget_repair_workflow branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/Madhusudhan-MSFT/winget-cli/actions/runs/7762264298/attempts/1'
Available 📚 dictionaries could cover words not in the 📘 dictionary

This includes both expected items (510) from .github/actions/spelling/expect.txt and unrecognized words (7)

Dictionary Entries Covers
cspell:win32/src/win32.txt 53509 20
cspell:python/src/python/python-lib.txt 3873 3
cspell:python/src/python/python.txt 453 2
cspell:python/src/common/extra.txt 741 2
cspell:php/php.txt 2597 2
cspell:npm/npm.txt 288 2
cspell:java/java.txt 7642 2
cspell:django/django.txt 859 2
cspell:csharp/csharp.txt 19 2
cspell:sql/src/tsql.txt 455 1

Consider adding them using (in .github/workflows/spelling3.yml):

      with:
        extra_dictionaries:
          cspell:win32/src/win32.txt
          cspell:python/src/python/python-lib.txt
          cspell:python/src/python/python.txt
          cspell:python/src/common/extra.txt
          cspell:php/php.txt
          cspell:npm/npm.txt
          cspell:java/java.txt
          cspell:django/django.txt
          cspell:csharp/csharp.txt
          cspell:sql/src/tsql.txt

To stop checking additional dictionaries, add:

      with:
        check_extra_dictionaries: ''
Errors (1)

See the 📜action log for details.

❌ Errors Count
❌ forbidden-pattern 1

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.