From dd38bbc817e86e5ff926429d89d7f072120df020 Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Tue, 5 May 2020 18:03:33 -0700 Subject: [PATCH] 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. --- .../PreIndexedPackageSourceFactory.cpp | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp b/src/AppInstallerRepositoryCore/Microsoft/PreIndexedPackageSourceFactory.cpp index 663645a6f56..b5fea6d3b79 100644 --- 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); } };