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

KSP-CKAN / CKAN / 15834236157

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

push

github

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

3880 of 9479 branches covered (40.93%)

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%)

0.88 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)
2✔
12
        {
2✔
13
            if (!stream.CanRead)
2!
14
            {
×
NEW
15
                throw new ArgumentException(nameof(stream));
×
16
            }
17
            this.progress = progress;
2✔
18
        }
2✔
19

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

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

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

46
        protected Stream ContainedStream => inner;
×
47

48
        public override bool CanRead  => inner.CanRead;
2✔
49
        public override bool CanSeek  => inner.CanSeek;
2✔
50
        public override bool CanWrite => inner.CanWrite;
×
51
        public override long Length   => inner.Length;
2✔
52
        public override long Position
53
        {
54
            get => inner.Position;
2✔
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);
2✔
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);
2✔
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