public async Task CompressAsync(List <FileHeader> fileHeaders, ArchiveStreamBase outputStream) { _outputStream = outputStream; _archiveProgress.Start(fileHeaders); var smallFiles = new List <FileHeader>(); foreach (var fileHeader in fileHeaders) { fileHeader.IsEncrypted = Settings.IsEncryptEnable; fileHeader.CompressionType = GenerateCompressionType(fileHeader.RelativePath); if (fileHeader.FileSize > Settings.ChunkSize) { await CompressBigFileAsync(fileHeader); } else { smallFiles.Add(fileHeader); } } await CompressSmallFiles(smallFiles); _outputStream = null; _archiveProgress.Reset(); }
public async Task DecompressAsync(ArchiveStreamBase inputStream, List <FileHeader> fileHeaders) { _inputStream = inputStream; _archiveProgress.Start(fileHeaders); var groupedFileHeaders = fileHeaders.Batch(Environment.ProcessorCount); foreach (var headers in groupedFileHeaders) { var tasks = headers.Select(DecompressFileAsync); await Task.WhenAll(tasks); } _inputStream = null; _archiveProgress.Reset(); }