Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PlexCleaner/SidecarFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private bool Update(bool modified = false)
public bool Open(bool modified = false)
{
// Open will Read, Create, Update
ToolInfoFailed = false;

// Make sure the sidecar file has been read or created
// If the sidecar file exists, read it
Expand Down Expand Up @@ -536,6 +537,7 @@ private bool SetJsonInfo(bool stampToolVersions)
private bool GetToolInfo()
{
Log.Debug("Reading media info from tools : {FileName}", _mediaFileInfo.FullName);
ToolInfoFailed = false;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

// Read the tool data text
if (
Expand Down
29 changes: 29 additions & 0 deletions PlexCleanerTests/SidecarFileFailureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,33 @@ public void Open_Sidecar_That_Cannot_Be_Written_Fails()
.Should()
.Contain(message => message.Contains("Failed to write JSON to file"));
}

[Fact]
public void Create_AfterFailedToolRead_ClearsToolInfoFailed()
{
string mediaFile = FakeTools.CopyUnverifiedSample(_directory);
FakeTools.WriteScript(Tools.MediaInfo.GetToolPath(), "exit 1\n");
SidecarFile sidecarFile = new(mediaFile);

_ = sidecarFile.Create().Should().BeFalse();
_ = sidecarFile.ToolInfoFailed.Should().BeTrue();

FakeTools.WriteSampleToolData(_directory);

_ = sidecarFile.Create().Should().BeTrue();
_ = sidecarFile.ToolInfoFailed.Should().BeFalse();
}

[Fact]
public void Open_AfterFailedToolRead_WithCurrentSidecar_ClearsToolInfoFailed()
{
string mediaFile = FakeTools.CopyUnverifiedSample(_directory);
FakeTools.WriteScript(Tools.MediaInfo.GetToolPath(), "exit 1\n");
SidecarFile sidecarFile = new(mediaFile);
_ = sidecarFile.Create().Should().BeFalse();
_ = sidecarFile.ToolInfoFailed.Should().BeTrue();

_ = sidecarFile.Open().Should().BeTrue();
_ = sidecarFile.ToolInfoFailed.Should().BeFalse();
}
}
Loading