winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit dd38bbc817e86e5ff926429d89d7f072120df020
parent adbb3da92635cdd07671aa3e2c7b265d342c7836
Author: JohnMcPMS <johnmcp@microsoft.com>
Date:   Tue,  5 May 2020 18:03:33 -0700

Change to download the source file first (#100)

## Change
Due to issues we are seeing with deploying directly from the URL, this change moves the client to download the msix file first, and deploy it from a local file.  This is intended to be a temporary measure until we can investigate the direct deployment issue further, but it may need to become permanent depending on the result of the investigation.

## Testing
Manually validated that the change works against the production environment with source add and automatic update.
Diffstat:
Msrc/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp | 30+++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp b/src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp @@ -182,17 +182,41 @@ namespace AppInstaller::Repository::Microsoft return; } - winrt::Windows::Foundation::Uri uri(Utility::ConvertToUTF16(packageLocation)); + // Due to complications with deployment, download the file and deploy from + // a local source while we investigate further. + bool download = Utility::IsUrlRemote(packageLocation); + std::filesystem::path tempFile; + winrt::Windows::Foundation::Uri uri = nullptr; + + if (download) + { + tempFile = Runtime::GetPathToTemp(); + tempFile /= GetPackageFullNameFromDetails(details) + ".msix"; + + Utility::Download(packageLocation, tempFile, progress); + + uri = winrt::Windows::Foundation::Uri(tempFile.c_str()); + } + else + { + uri = winrt::Windows::Foundation::Uri(Utility::ConvertToUTF16(packageLocation)); + } + Deployment::RequestAddPackage( uri, winrt::Windows::Management::Deployment::DeploymentOptions::None, progress); + + if (download) + { + // If successful, delete the file + std::filesystem::remove(tempFile); + } } void RemoveInternal(const SourceDetails& details, IProgressCallback& callback) override { - // Begin package removal, but let it run its course without waiting. - AICLI_LOG(Repo, Info, << "Removing package " << GetPackageFullNameFromDetails(details)); + AICLI_LOG(Repo, Info, << "Removing package: " << GetPackageFullNameFromDetails(details)); Deployment::RemovePackage(GetPackageFullNameFromDetails(details), callback); } };