Skip to content

Commit

Permalink
Default to temp folder
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed Dec 23, 2024
1 parent 9740c2f commit 1a43052
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Svrooij.WinTuner.CmdLets/Commands/ShowMsiInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ShowMsiInfo : DependencyCmdlet<Startup>
/// <summary>
/// <para type="description">Path to save the MSI file</para>
/// </summary>
[Parameter(Mandatory = true, Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = nameof(MsiUrl))]
[Parameter(Mandatory = false, Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = nameof(MsiUrl))]
public string? OutputPath { get; set; }

/// <summary>
Expand All @@ -69,7 +69,7 @@ public override async Task ProcessRecordAsync(CancellationToken cancellationToke
else if (MsiUrl is not null)
{
logger?.LogInformation("Downloading MSI from URL to {OutputPath}: {MsiUrl}", MsiUrl, OutputPath);
var outputFile = Path.Combine(OutputPath!, OutputFilename ?? Path.GetFileName(MsiUrl.LocalPath));
var outputFile = Path.Combine(OutputPath ?? Path.GetTempPath(), OutputFilename ?? Path.GetFileName(MsiUrl.LocalPath));
// The file managed does automatic chunking of the download, so it will also work for very large files.
await fileManager!.DownloadFileAsync(MsiUrl!.ToString(), outputFile, cancellationToken: cancellationToken);
MsiPath = outputFile;
Expand Down
3 changes: 1 addition & 2 deletions tests/WinTuner.Cmdlets.Tests/Show-MsiInfo.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Describe 'Show-MsiInfo' {

It 'Should download and show MSI info' {
$msiUrl = 'https://download.microsoft.com/download/C/7/A/C7AAD914-A8A6-4904-88A1-29E657445D03/LAPS.x64.msi'
$tempFolder = $env:TEMP
$msiInfo = $(Show-MsiInfo -MsiUrl $msiUrl -OutputPath $tempFolder)
$msiInfo = $(Show-MsiInfo -MsiUrl $msiUrl)
$msiInfo | Should -Not -BeNullOrEmpty
$msiInfo.ProductCode | Should -Be '{97E2CA7B-B657-4FF7-A6DB-30ECC73E1E28}'
$msiInfo.ProductVersion | Should -Be '6.2.0.0'
Expand Down

0 comments on commit 1a43052

Please sign in to comment.