< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.ClientEvent.ClientEventLogger
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs
Line coverage
92%
Covered lines: 12
Uncovered lines: 1
Coverable lines: 13
Total lines: 42
Line coverage: 92.3%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/2/2026 - 12:12:50 AM Line coverage: 0% (0/9) Total lines: 347/22/2026 - 12:16:22 AM Line coverage: 92.3% (12/13) Branch coverage: 50% (3/6) Total lines: 42 7/22/2026 - 12:16:22 AM Line coverage: 92.3% (12/13) Branch coverage: 50% (3/6) Total lines: 42

Coverage delta

Coverage delta 93 -93

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
WriteDocumentAsync()50%6690.9%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using System.Threading.Tasks;
 4using Jellyfin.Extensions;
 5
 6namespace MediaBrowser.Controller.ClientEvent
 7{
 8    /// <inheritdoc />
 9    public class ClientEventLogger : IClientEventLogger
 10    {
 11        private readonly IServerApplicationPaths _applicationPaths;
 12
 13        /// <summary>
 14        /// Initializes a new instance of the <see cref="ClientEventLogger"/> class.
 15        /// </summary>
 16        /// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
 17        public ClientEventLogger(IServerApplicationPaths applicationPaths)
 18        {
 419            _applicationPaths = applicationPaths;
 420        }
 21
 22        /// <inheritdoc />
 23        public async Task<string> WriteDocumentAsync(string clientName, string clientVersion, Stream fileContents)
 24        {
 425            var safeClientName = PathHelper.GetSafeLeafFileName(clientName) ?? "unknown-client";
 426            var safeClientVersion = PathHelper.GetSafeLeafFileName(clientVersion) ?? "unknown-version";
 427            var fileName = $"upload_{safeClientName}_{safeClientVersion}_{DateTime.UtcNow:yyyyMMddHHmmss}_{Guid.NewGuid(
 428            var logFilePath = Path.Combine(_applicationPaths.LogDirectoryPath, fileName);
 429            if (!PathHelper.IsContainedIn(_applicationPaths.LogDirectoryPath, logFilePath))
 30            {
 031                throw new ArgumentException("Path resolved to filename not in log directory");
 32            }
 33
 434            var fileStream = new FileStream(logFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.None);
 435            await using (fileStream.ConfigureAwait(false))
 36            {
 437                await fileContents.CopyToAsync(fileStream).ConfigureAwait(false);
 438                return fileName;
 39            }
 440        }
 41    }
 42}