|
@@ -1,3 +1,7 @@
|
|
|
+using System;
|
|
|
+using System.Diagnostics.CodeAnalysis;
|
|
|
+using System.IO;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
using AutoFixture;
|
|
|
using AutoFixture.AutoMoq;
|
|
|
using Emby.Server.Implementations.IO;
|
|
@@ -38,5 +42,26 @@ namespace Jellyfin.Server.Implementations.Tests.IO
|
|
|
Assert.Equal(expectedAbsolutePath, generatedPath);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ [SkippableFact]
|
|
|
+ public void GetFileInfo_DanglingSymlink_ExistsFalse()
|
|
|
+ {
|
|
|
+ Skip.If(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
|
|
|
+
|
|
|
+ string testFileDir = Path.Combine(Path.GetTempPath(), "jellyfin-test-data");
|
|
|
+ string testFileName = Path.Combine(testFileDir, Path.GetRandomFileName() + "-danglingsym.link");
|
|
|
+
|
|
|
+ Directory.CreateDirectory(testFileDir);
|
|
|
+ Assert.Equal(0, symlink("thispathdoesntexist", testFileName));
|
|
|
+ Assert.True(File.Exists(testFileName));
|
|
|
+
|
|
|
+ var metadata = _sut.GetFileInfo(testFileName);
|
|
|
+ Assert.False(metadata.Exists);
|
|
|
+ }
|
|
|
+
|
|
|
+ [SuppressMessage("Naming Rules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Have to")]
|
|
|
+ [DllImport("libc", SetLastError = true, CharSet = CharSet.Ansi)]
|
|
|
+ [DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
|
+ private static extern int symlink(string target, string linkpath);
|
|
|
}
|
|
|
}
|