Esempio n. 1
0
        private async Task <object> GetFileStream()
        {
            var  totalLength = Length;
            long glostart    = _start ?? 0;
            long gloend      = _end == null ||
                               _start == _end && _end == 0 ? totalLength : _end.Value + 1;

            long fileStart = 0;
            long fileEnd   = 0;

            foreach (var file in _files)
            {
                var clofile = file;

                fileEnd += clofile.OriginalSize;

                if (glostart >= fileEnd || gloend <= fileStart)
                {
                    fileStart += clofile.OriginalSize;
                    continue;
                }

                long clostart = Math.Max(0, glostart - fileStart);
                long cloend   = gloend - fileStart - 1;

                await Download(clostart, cloend, clofile).ConfigureAwait(false);

                fileStart += file.OriginalSize;
            }

            _innerStream.Flush();

            return(_innerStream);
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (!disposing)
            {
                return;
            }

            _innerStream?.Flush();
            _copyTask?.Wait();

            _innerStream?.Close();
        }
Esempio n. 3
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (!disposing)
            {
                return;
            }

            _cancellationTokenSource.Cancel();

            _innerStream?.Flush();
            //_copyTask?.Wait();

            _innerStream?.Close();
        }