< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.ClientEvent.ClientEventLogger
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 34
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%

File(s)

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

#LineLine coverage
 1using System;
 2using System.IO;
 3using System.Threading.Tasks;
 4
 5namespace MediaBrowser.Controller.ClientEvent
 6{
 7    /// <inheritdoc />
 8    public class ClientEventLogger : IClientEventLogger
 9    {
 10        private readonly IServerApplicationPaths _applicationPaths;
 11
 12        /// <summary>
 13        /// Initializes a new instance of the <see cref="ClientEventLogger"/> class.
 14        /// </summary>
 15        /// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param>
 16        public ClientEventLogger(IServerApplicationPaths applicationPaths)
 17        {
 018            _applicationPaths = applicationPaths;
 019        }
 20
 21        /// <inheritdoc />
 22        public async Task<string> WriteDocumentAsync(string clientName, string clientVersion, Stream fileContents)
 23        {
 24            var fileName = $"upload_{clientName}_{clientVersion}_{DateTime.UtcNow:yyyyMMddHHmmss}_{Guid.NewGuid():N}.log
 25            var logFilePath = Path.Combine(_applicationPaths.LogDirectoryPath, fileName);
 26            var fileStream = new FileStream(logFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.None);
 27            await using (fileStream.ConfigureAwait(false))
 28            {
 29                await fileContents.CopyToAsync(fileStream).ConfigureAwait(false);
 30                return fileName;
 31            }
 32        }
 33    }
 34}