Repository navigation
Treat an FfMpeg Verify That Did Not Run as a Tool Error #1089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
26bc869
Treat an FfMpeg Verify That Did Not Run as a Tool Error
ptr727 29766ab
Test the VerifyAndRepair Tool Error Path and Mark S16
ptr727 ee0b738
State the canRepair Contract and the S16 Delete
ptr727 1b4762b
Name RepairTimestamps in the S16 Delete Guard
ptr727 0019afd
Narrow ToolError to a Launch Failure or Cancel and Mark S17
ptr727 06206a5
Include a Throw After Launch in the ToolError Wording
ptr727 26a170e
Drop the Timing Qualifier From the ToolError Wording
ptr727 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| using System.Text.Json.Nodes; | ||
| using AwesomeAssertions; | ||
| using PlexCleaner; | ||
| using Xunit; | ||
|
|
||
| namespace PlexCleanerTests; | ||
|
|
||
| [Collection("Sequential")] | ||
| public sealed class VerifyToolErrorTests : IDisposable | ||
| { | ||
| private readonly string _directory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
| private readonly ToolsOptions1 _toolsOptions = Program.Config.ToolsOptions; | ||
| private readonly bool _verify = Program.Config.ProcessOptions.Verify; | ||
| private readonly bool _useSidecarFiles = Program.Config.ProcessOptions.UseSidecarFiles; | ||
| private readonly bool _autoRepair = Program.Config.VerifyOptions.AutoRepair; | ||
| private readonly bool _deleteInvalidFiles = Program.Config.VerifyOptions.DeleteInvalidFiles; | ||
| private readonly MediaToolInfo _ffProbeInfo = Tools.FfProbe.Info; | ||
| private readonly MediaToolInfo _mkvMergeInfo = Tools.MkvMerge.Info; | ||
| private readonly MediaToolInfo _mediaInfoInfo = Tools.MediaInfo.Info; | ||
|
|
||
| public VerifyToolErrorTests() | ||
| { | ||
| _ = Directory.CreateDirectory(_directory); | ||
| Program.Config.ProcessOptions.Verify = true; | ||
| Program.Config.ProcessOptions.UseSidecarFiles = true; | ||
| Program.Config.VerifyOptions.AutoRepair = true; | ||
| Program.Config.VerifyOptions.DeleteInvalidFiles = true; | ||
|
|
||
| // An empty tools folder makes every tool fail to launch | ||
| Program.Config.ToolsOptions = new ToolsOptions1 | ||
| { | ||
| UseSystem = false, | ||
| RootRelative = false, | ||
| RootPath = _directory, | ||
| }; | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| Program.Config.ToolsOptions = _toolsOptions; | ||
| Tools.FfProbe.Info = _ffProbeInfo; | ||
| Tools.MkvMerge.Info = _mkvMergeInfo; | ||
| Tools.MediaInfo.Info = _mediaInfoInfo; | ||
| Program.Config.ProcessOptions.Verify = _verify; | ||
| Program.Config.ProcessOptions.UseSidecarFiles = _useSidecarFiles; | ||
| Program.Config.VerifyOptions.AutoRepair = _autoRepair; | ||
| Program.Config.VerifyOptions.DeleteInvalidFiles = _deleteInvalidFiles; | ||
| Directory.Delete(_directory, true); | ||
| } | ||
|
|
||
| private string CreateFile(string name) | ||
| { | ||
| string fileName = Path.Combine(_directory, name); | ||
| File.WriteAllText(fileName, ""); | ||
| return fileName; | ||
| } | ||
|
|
||
| // The sample sidecar supplies the media props, so only the verify needs a tool | ||
| private string CopyUnverifiedSample() | ||
| { | ||
| Tools.FfProbe.Info = new MediaToolInfo(Tools.FfProbe) { Version = "8.0.1" }; | ||
| Tools.MkvMerge.Info = new MediaToolInfo(Tools.MkvMerge) { Version = "96.0" }; | ||
| Tools.MediaInfo.Info = new MediaToolInfo(Tools.MediaInfo) { Version = "25.10" }; | ||
|
|
||
| string sampleDirectory = PlexCleanerFixture.GetSamplesAbsoluteDirectory(); | ||
| string mediaFile = Path.Combine(_directory, "name.mkv"); | ||
| File.Copy(Path.Combine(sampleDirectory, "Sidecar.v5.mkv"), mediaFile); | ||
|
|
||
| JsonNode sidecar = JsonNode.Parse( | ||
| File.ReadAllText(Path.Combine(sampleDirectory, "Sidecar.v5.PlexCleaner")) | ||
| )!; | ||
| sidecar["State"] = (int)SidecarFile.StatesType.None; | ||
| File.WriteAllText(Path.Combine(_directory, "name.PlexCleaner"), sidecar.ToJsonString()); | ||
| return mediaFile; | ||
| } | ||
|
|
||
| [Fact] | ||
| public void VerifyMedia_ToolDoesNotRun_IsToolError() => | ||
| _ = Tools.FfMpeg.VerifyMedia(CreateFile("name.mkv")).Should().Be(VerifyResult.ToolError); | ||
|
|
||
| [Fact] | ||
| public void VerifyAndRepair_ToolError_KeepsStateAndFiles() | ||
| { | ||
| string mediaFile = CopyUnverifiedSample(); | ||
| string sidecarFile = Path.ChangeExtension(mediaFile, ".PlexCleaner"); | ||
| ProcessFile processFile = new(mediaFile); | ||
| _ = processFile.GetMediaProps().Should().BeTrue(); | ||
|
|
||
| bool modified = false; | ||
| _ = processFile.VerifyAndRepair(ref modified).Should().BeFalse(); | ||
| _ = processFile.State.Should().Be(SidecarFile.StatesType.None); | ||
| _ = processFile.DeleteFailedFile().Should().BeFalse(); | ||
|
|
||
| _ = modified.Should().BeFalse(); | ||
| _ = File.Exists(mediaFile).Should().BeTrue(); | ||
| _ = File.Exists(sidecarFile).Should().BeTrue(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void RepairTimestamps_ToolError_KeepsFiles() | ||
| { | ||
| string mediaFile = CreateFile("name.mkv"); | ||
| string sidecarFile = CreateFile("name.PlexCleaner"); | ||
| ProcessFile processFile = new(mediaFile); | ||
|
|
||
| bool modified = false; | ||
| _ = processFile.RepairTimestamps(ref modified).Should().BeFalse(); | ||
| _ = processFile.DeleteFailedFile().Should().BeFalse(); | ||
|
|
||
| _ = File.Exists(mediaFile).Should().BeTrue(); | ||
| _ = File.Exists(sidecarFile).Should().BeTrue(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.