Suggestions from review

This commit is contained in:
Cody Robibero
2021-10-27 19:20:14 -06:00
parent a6357f89ab
commit c534c45033
5 changed files with 59 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.ClientLog;
using Microsoft.Extensions.Logging;
@@ -43,10 +44,9 @@ namespace MediaBrowser.Controller.ClientEvent
}
/// <inheritdoc />
public async Task WriteFileAsync(string fileName, Stream fileContents)
public async Task WriteDocumentAsync(AuthorizationInfo authorizationInfo, Stream fileContents)
{
// Force naming convention: upload_YYYYMMDD_$name
fileName = $"upload_{DateTime.UtcNow:yyyyMMdd}_{fileName}";
var fileName = $"upload_{authorizationInfo.Client}_{authorizationInfo.Version}_{DateTime.UtcNow:yyyyMMddHHmmss}.log";
var logFilePath = Path.Combine(_applicationPaths.LogDirectoryPath, fileName);
await using var fileStream = new FileStream(logFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.None);
await fileContents.CopyToAsync(fileStream).ConfigureAwait(false);

View File

@@ -1,5 +1,6 @@
using System.IO;
using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.ClientLog;
namespace MediaBrowser.Controller.ClientEvent
@@ -18,9 +19,9 @@ namespace MediaBrowser.Controller.ClientEvent
/// <summary>
/// Writes a file to the log directory.
/// </summary>
/// <param name="fileName">The file name.</param>
/// <param name="fileContents">The file contents.</param>
/// <param name="authorizationInfo">The current authorization info.</param>
/// <param name="fileContents">The file contents to write.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
Task WriteFileAsync(string fileName, Stream fileContents);
Task WriteDocumentAsync(AuthorizationInfo authorizationInfo, Stream fileContents);
}
}