Merge pull request #581 from rosenbjerg/include-more-guid-chars-in-pipe-path

Include more guid chars in pipe path
This commit is contained in:
Malte Rosenbjerg 2025-10-17 20:34:45 +02:00 committed by GitHub
commit 46fb46381d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 3 deletions

View file

@ -1,6 +1,7 @@
using System.Drawing; using System.Drawing;
using FFMpegCore.Arguments; using FFMpegCore.Arguments;
using FFMpegCore.Enums; using FFMpegCore.Enums;
using FFMpegCore.Pipes;
namespace FFMpegCore.Test; namespace FFMpegCore.Test;
@ -8,6 +9,7 @@ namespace FFMpegCore.Test;
public class ArgumentBuilderTest public class ArgumentBuilderTest
{ {
private readonly string[] _concatFiles = { "1.mp4", "2.mp4", "3.mp4", "4.mp4" }; private readonly string[] _concatFiles = { "1.mp4", "2.mp4", "3.mp4", "4.mp4" };
private readonly int _macOsMaxPipePathLength = 104;
private readonly string[] _multiFiles = { "1.mp3", "2.mp3", "3.mp3", "4.mp3" }; private readonly string[] _multiFiles = { "1.mp3", "2.mp3", "3.mp3", "4.mp3" };
[TestMethod] [TestMethod]
@ -703,4 +705,18 @@ public class ArgumentBuilderTest
var arg = new AudibleEncryptionKeyArgument("62689101"); var arg = new AudibleEncryptionKeyArgument("62689101");
Assert.AreEqual("-activation_bytes 62689101", arg.Text); Assert.AreEqual("-activation_bytes 62689101", arg.Text);
} }
[TestMethod]
public void InputPipe_MaxLength_ShorterThanMacOSMax()
{
var pipePath = new InputPipeArgument(new StreamPipeSource(Stream.Null)).PipePath;
Assert.IsLessThan(104, pipePath.Length);
}
[TestMethod]
public void OutputPipe_MaxLength_ShorterThanMacOSMax()
{
var pipePath = new OutputPipeArgument(new StreamPipeSink(Stream.Null)).PipePath;
Assert.IsLessThan(_macOsMaxPipePathLength, pipePath.Length);
}
} }

View file

@ -11,7 +11,7 @@ public abstract class PipeArgument
protected PipeArgument(PipeDirection direction) protected PipeArgument(PipeDirection direction)
{ {
PipeName = PipeHelpers.GetUnqiuePipeName(); PipeName = PipeHelpers.GetUniquePipeName();
_direction = direction; _direction = direction;
} }

View file

@ -4,9 +4,9 @@ namespace FFMpegCore.Pipes;
internal static class PipeHelpers internal static class PipeHelpers
{ {
public static string GetUnqiuePipeName() public static string GetUniquePipeName()
{ {
return $"FFMpegCore_{Guid.NewGuid().ToString("N").Substring(0, 5)}"; return $"FFMpegCore_{Guid.NewGuid().ToString("N").Substring(0, 16)}";
} }
public static string GetPipePath(string pipeName) public static string GetPipePath(string pipeName)