New: Add additional logging when renaming extra files

Closes #5890
This commit is contained in:
Mark McDowall 2023-08-09 17:42:09 -07:00
parent 6b533ef2f9
commit 1ae0dc81f7
4 changed files with 20 additions and 3 deletions

View File

@ -1,4 +1,4 @@
using System;
using System;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Extras.Files
@ -12,5 +12,10 @@ namespace NzbDrone.Core.Extras.Files
public DateTime Added { get; set; }
public DateTime LastUpdated { get; set; }
public string Extension { get; set; }
public override string ToString()
{
return $"[{Id}] {RelativePath}";
}
}
}

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -86,6 +86,8 @@ namespace NzbDrone.Core.Extras.Files
protected TExtraFile MoveFile(Series series, EpisodeFile episodeFile, TExtraFile extraFile, string fileNameSuffix = null)
{
_logger.Trace("Renaming extra file: {0}", extraFile);
var newFolder = Path.GetDirectoryName(Path.Combine(series.Path, episodeFile.RelativePath));
var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(episodeFile.RelativePath));
@ -103,9 +105,13 @@ namespace NzbDrone.Core.Extras.Files
{
try
{
_logger.Trace("Renaming extra file: {0} to {1}", extraFile, newFileName);
_diskProvider.MoveFile(existingFileName, newFileName);
extraFile.RelativePath = series.Path.GetRelativePath(newFileName);
_logger.Trace("Renamed extra file from: {0}", extraFile);
return extraFile;
}
catch (Exception ex)

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.Languages;
@ -18,5 +18,10 @@ namespace NzbDrone.Core.Extras.Subtitles
public List<string> LanguageTags { get; set; }
private string LanguageTagsAsString => string.Join(".", LanguageTags);
public override string ToString()
{
return $"[{Id}] {RelativePath} ({Language}{(LanguageTags.Count > 0 ? "." : "")}{LanguageTagsAsString}{Extension})";
}
}
}

View File

@ -82,6 +82,7 @@ namespace NzbDrone.Core.Extras.Subtitles
foreach (var subtitleFile in group)
{
var suffix = GetSuffix(subtitleFile.Language, copy, subtitleFile.LanguageTags, groupCount > 1);
movedFiles.AddIfNotNull(MoveFile(series, episodeFile, subtitleFile, suffix));
copy++;