Add ProcessedItems property to ZipCreationResult

 ENHANCED ZIP RESULT INFORMATION:

� NEW PROCESSEDITEM PROPERTY:
  • Added List<object> ProcessedItems to ZipCreationResult
  • Contains all FileInfo and DirectoryInfo objects that were processed
  • Provides detailed information about what was included in the archive
  • Useful for auditing, logging, and post-processing analysis

� IMPLEMENTATION DETAILS:
  • Tracks items during AddFiles() and AddDirectory() operations
  • For directories: includes both the DirectoryInfo and all contained FileInfo objects
  • For file collections: includes all FileInfo objects
  • Creates a copy of the list in CreateResult() to prevent modification

� USAGE EXAMPLES:
  $result = New-MinIOZipArchive -Directory 'C:\MyFiles' -DestinationPath 'archive.zip'
  $result.ProcessedItems | Where-Object { $_ -is [System.IO.FileInfo] } | Select-Object Name, Length
  $result.ProcessedItems | Where-Object { $_ -is [System.IO.DirectoryInfo] } | Select-Object Name

 BENEFITS:
  • Complete audit trail of processed items
  • Easy filtering by FileInfo vs DirectoryInfo
  • Detailed file information (size, dates, attributes)
  • Support for post-processing workflows
  • Enhanced logging and reporting capabilities

Now zip results include comprehensive information about all processed items!
This commit is contained in:
PSMinIO Developer
2025-07-14 16:56:56 -04:00
parent 4c2ef37a07
commit 75778fcfd3
3 changed files with 11 additions and 1 deletions
Binary file not shown.
Binary file not shown.
+11 -1
View File
@@ -18,6 +18,7 @@ namespace PSMinIO.Utils
private readonly ThreadSafeProgressCollector _progressCollector;
private bool _disposed = false;
private int _totalFiles = 0;
private readonly List<object> _processedItems = new List<object>();
// Activity IDs for progress tracking
private const int ZipActivityId = 10;
@@ -89,6 +90,9 @@ namespace PSMinIO.Utils
_totalFiles = fileList.Count;
var totalSize = fileList.OfType<FileInfo>().Sum(f => f.Length);
// Track the processed items
_processedItems.AddRange(fileList);
MinIOLogger.WriteVerbose(_cmdlet, "Starting zip compression: {0} files, {1} total size",
_totalFiles, SizeFormatter.FormatBytes(totalSize));
@@ -113,6 +117,10 @@ namespace PSMinIO.Utils
_totalFiles = files.Length;
var totalSize = files.Sum(f => f.Length);
// Track the processed directory and its files
_processedItems.Add(directoryInfo);
_processedItems.AddRange(files);
MinIOLogger.WriteVerbose(_cmdlet, "Adding directory to zip: {0} ({1} files, {2})",
directoryInfo.Name, _totalFiles, SizeFormatter.FormatBytes(totalSize));
@@ -220,7 +228,8 @@ namespace PSMinIO.Utils
TotalUncompressedSize = _zipBuilder.TotalUncompressedSize,
TotalCompressedSize = _zipBuilder.TotalCompressedSize,
CompressionRatio = _zipBuilder.CompressionRatio,
SpaceSaved = _zipBuilder.TotalUncompressedSize - _zipBuilder.TotalCompressedSize
SpaceSaved = _zipBuilder.TotalUncompressedSize - _zipBuilder.TotalCompressedSize,
ProcessedItems = new List<object>(_processedItems) // Create a copy of the processed items
};
}
@@ -252,6 +261,7 @@ namespace PSMinIO.Utils
public long TotalCompressedSize { get; set; }
public double CompressionRatio { get; set; }
public long SpaceSaved { get; set; }
public List<object> ProcessedItems { get; set; } = new List<object>();
public double CompressionEfficiency => (1 - CompressionRatio) * 100;
public double AverageSpeed => Duration.TotalSeconds > 0 ? TotalUncompressedSize / Duration.TotalSeconds : 0;
}