Skip to content

Commit

Permalink
New: Add additional logging when renaming extra files
Browse files Browse the repository at this point in the history
Closes #5890
  • Loading branch information
markus101 committed Aug 10, 2023
1 parent 6b533ef commit 1ae0dc8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/NzbDrone.Core/Extras/Files/ExtraFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using NzbDrone.Core.Datastore;

namespace NzbDrone.Core.Extras.Files
Expand All @@ -12,5 +12,10 @@ public abstract class ExtraFile : ModelBase
public DateTime Added { get; set; }
public DateTime LastUpdated { get; set; }
public string Extension { get; set; }

public override string ToString()
{
return $"[{Id}] {RelativePath}";
}
}
}
8 changes: 7 additions & 1 deletion src/NzbDrone.Core/Extras/Files/ExtraFileManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -86,6 +86,8 @@ protected TExtraFile ImportFile(Series series, EpisodeFile episodeFile, string p

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));

Expand All @@ -103,9 +105,13 @@ protected TExtraFile MoveFile(Series series, EpisodeFile episodeFile, TExtraFile
{
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)
Expand Down
7 changes: 6 additions & 1 deletion src/NzbDrone.Core/Extras/Subtitles/SubtitleFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.Languages;

Expand All @@ -18,5 +18,10 @@ public SubtitleFile()
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})";
}
}
}
1 change: 1 addition & 0 deletions src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public override IEnumerable<ExtraFile> MoveFilesAfterRename(Series series, List<
foreach (var subtitleFile in group)
{
var suffix = GetSuffix(subtitleFile.Language, copy, subtitleFile.LanguageTags, groupCount > 1);

movedFiles.AddIfNotNull(MoveFile(series, episodeFile, subtitleFile, suffix));

copy++;
Expand Down

0 comments on commit 1ae0dc8

Please sign in to comment.