Skip to content

Commit

Permalink
perf: An error log file will only be created when there are songs tha…
Browse files Browse the repository at this point in the history
…t failed to download.
  • Loading branch information
real-zony committed May 24, 2023
1 parent 41cba02 commit 1e5c418
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ZonyLrcTools.Common/Lyrics/LyricsDownloader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;
using System.Collections.Immutable;
using System.Text;
using Microsoft.Extensions.Options;
using Polly;
using ZonyLrcTools.Common.Configuration;
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
using ZonyLrcTools.Common.Infrastructure.Exceptions;
Expand Down Expand Up @@ -134,12 +134,18 @@ private byte[] Utf8ToSelectedEncoding(LyricsItemCollection lyrics)
return Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding(_options.Provider.Lyric.Config.FileEncoding), lyrics.GetUtf8Bytes());
}

private async Task LogFailedSongFilesInfo(string outFilePath, List<MusicInfo> musicInfos)
private async Task LogFailedSongFilesInfo(string outFilePath, IEnumerable<MusicInfo> musicInfos)
{
var failedSongList = musicInfos.Where(m => m.IsSuccessful == false).ToImmutableList();
if (!failedSongList.Any())
{
return;
}

var failedSongFiles = new StringBuilder();
failedSongFiles.AppendLine("歌曲名,歌手,路径");

foreach (var failedSongFile in musicInfos.Where(m => m.IsSuccessful == false))
foreach (var failedSongFile in failedSongList)
{
failedSongFiles.AppendLine($"{failedSongFile.Name},{failedSongFile.Artist},{failedSongFile.FilePath}");
}
Expand Down

0 comments on commit 1e5c418

Please sign in to comment.