• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KSP-CKAN / CKAN / 15833572503

23 Jun 2025 07:42PM UTC coverage: 42.236% (+0.1%) from 42.099%
15833572503

push

github

HebaruSan
Merge #4398 Exception handling revamp, parallel multi-host inflation

3881 of 9479 branches covered (40.94%)

Branch coverage included in aggregate %.

48 of 137 new or added lines in 30 files covered. (35.04%)

12 existing lines in 6 files now uncovered.

8334 of 19442 relevant lines covered (42.87%)

3.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.42
/Core/Repositories/ReadProgressStream.cs
1
using System;
2
using System.IO;
3

4
// https://learn.microsoft.com/en-us/archive/msdn-magazine/2006/december/net-matters-deserialization-progress-and-more
5

6
namespace CKAN
7
{
8
    public class ReadProgressStream : ContainerStream
9
    {
10
        public ReadProgressStream(Stream stream, IProgress<long>? progress)
11
            : base(stream)
8✔
12
        {
8✔
13
            if (!stream.CanRead)
8!
14
            {
×
NEW
15
                throw new ArgumentException(nameof(stream));
×
16
            }
17
            this.progress = progress;
8✔
18
        }
8✔
19

20
        public override int Read(byte[] buffer, int offset, int count)
21
        {
8✔
22
            int amountRead = base.Read(buffer, offset, count);
8✔
23
            if (progress != null)
8✔
24
            {
8✔
25
                long newProgress = Position;
8✔
26
                if (newProgress > lastProgress)
8✔
27
                {
8✔
28
                    progress?.Report(newProgress);
8!
29
                    lastProgress = newProgress;
8✔
30
                }
8✔
31
            }
8✔
32
            return amountRead;
8✔
33
        }
8✔
34

35
        private readonly IProgress<long>? progress;
36
        private          long             lastProgress = 0;
8✔
37
    }
38

39
    public abstract class ContainerStream : Stream
40
    {
41
        protected ContainerStream(Stream stream)
8✔
42
        {
8✔
43
            inner = stream;
8✔
44
        }
8✔
45

46
        protected Stream ContainedStream => inner;
×
47

48
        public override bool CanRead  => inner.CanRead;
8✔
49
        public override bool CanSeek  => inner.CanSeek;
8✔
50
        public override bool CanWrite => inner.CanWrite;
×
51
        public override long Length   => inner.Length;
8✔
52
        public override long Position
53
        {
54
            get => inner.Position;
8✔
55
            #pragma warning disable IDE0027
56
            set
57
            {
×
58
                inner.Position = value;
×
59
            }
×
60
            #pragma warning restore IDE0027
61
        }
62
        public override void Flush()
63
        {
×
64
            inner.Flush();
×
65
        }
×
66
        public override int Read(byte[] buffer, int offset, int count)
67
            => inner.Read(buffer, offset, count);
8✔
68

69
        public override void Write(byte[] buffer, int offset, int count)
70
        {
×
71
            inner.Write(buffer, offset, count);
×
72
        }
×
73
        public override void SetLength(long length)
74
        {
×
75
            inner.SetLength(length);
×
76
        }
×
77
        public override long Seek(long offset, SeekOrigin origin)
78
            => inner.Seek(offset, origin);
8✔
79

80
        private readonly Stream inner;
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc