Skip to content

Commit

Permalink
Add more logging for unpacking zip
Browse files Browse the repository at this point in the history
  • Loading branch information
alerickson committed Oct 28, 2024
1 parent f81cd25 commit 51d46f5
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions src/code/InstallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -971,19 +971,17 @@ private bool TryInstallToTempPath(
updatedPackagesHash = packagesHash;
try
{
var pathToFile = Path.Combine(tempInstallPath, $"{pkgName}.{normalizedPkgVersion}.zip");
_cmdletPassedIn.WriteVerbose($"pathToFile IS: {pathToFile}.");

if (File.Exists(pathToFile))
if (responseStream == null)
{
_cmdletPassedIn.WriteVerbose($"pathToFile EXISTS.");

_cmdletPassedIn.WriteVerbose($"response stream is null");
}
else {
_cmdletPassedIn.WriteVerbose($"pathToFile DOES NOT EXIST.");

_cmdletPassedIn.WriteVerbose($"response stream is NOT null");
}

var pathToFile = Path.Combine(tempInstallPath, $"{pkgName}.{normalizedPkgVersion}.zip");
_cmdletPassedIn.WriteVerbose($"pathToFile IS: {pathToFile}.");

using var fs = File.Create(pathToFile);
responseStream.Seek(0, System.IO.SeekOrigin.Begin);
responseStream.CopyTo(fs);
Expand All @@ -1000,6 +998,35 @@ private bool TryInstallToTempPath(
return false;
}


_cmdletPassedIn.WriteVerbose($"tempDirNameVersionIS: {tempDirNameVersion}.");

// Check if the directory exists
if (Directory.Exists(tempDirNameVersion))
{
Console.WriteLine($"Contents of {tempDirNameVersion}:");

// Display all files in the directory
string[] files = Directory.GetFiles(tempDirNameVersion, "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
Console.WriteLine($"File: {file}");
}

// Display all subdirectories in the directory
string[] directories = Directory.GetDirectories(tempDirNameVersion, "*", SearchOption.AllDirectories);
foreach (string directory in directories)
{
Console.WriteLine($"Directory: {directory}");
}
}
else
{
Console.WriteLine($"The directory {tempDirNameVersion} does not exist.");
}



File.Delete(pathToFile);

var moduleManifest = Path.Combine(tempDirNameVersion, pkgName + PSDataFileExt);
Expand Down

0 comments on commit 51d46f5

Please sign in to comment.