Exemplo n.º 1
0
        public async Task AppendAsync(Stream stream, IArchiveFileEntry fileEntry)
        {
            var filesystemTarget = GetEntryPath(fileEntry);

            if (ExistsWithMatchingHash(fileEntry, filesystemTarget))
            {
                return;
            }
            Directory.CreateDirectory(Path.GetDirectoryName(filesystemTarget));
            using (var fileStream = File.Open(filesystemTarget, FileMode.Create, FileAccess.ReadWrite,
                                              FileShare.ReadWrite))
            {
                var source = Archive.HandleCompression(fileEntry, stream);

                void ProgressCallback(long length, long progress)
                {
                    var eventArgs = new ProgressUpdateEventArgs(fileEntry, progress, fileEntry.UncompressedSize);

                    OnProgressUpdated(eventArgs);
                }

                try
                {
                    await source.CopyToAsync(fileStream, ProgressCallback);
                }
                finally
                {
                    if (source != stream)
                    {
                        source.Close();
                        source.Dispose();
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void PatchWriter_ProgressUpdated(object sender, ProgressUpdateEventArgs e)
 {
     OnProgress(e);
 }
Exemplo n.º 3
0
 protected virtual void OnProgress(ProgressUpdateEventArgs e)
 {
     Progress?.Invoke(this, e);
 }
Exemplo n.º 4
0
 private void OnProgressUpdated(ProgressUpdateEventArgs eventArgs)
 {
     ProgressUpdated?.Invoke(this, eventArgs);
 }