fix: handle directory.Exists caching

This commit is contained in:
Dylan R. E. Moonfire 2021-12-06 23:02:23 -06:00
parent b95c6b4bf5
commit 233656abb9

View file

@ -29,7 +29,7 @@ namespace MfGames.IO.Extensions
directory.Parent.CreateIfMissing();
// If the directory doesn't exist, create it.
if (!directory.Exists)
if (!Directory.Exists(directory.FullName))
{
directory.Create();
}
@ -84,8 +84,9 @@ namespace MfGames.IO.Extensions
}
// If the directory is null, just return null. Same with
// non-existing directories.
if (directory is not { Exists: true })
// non-existing directories. We don't use directory.Exists here
// because it seems to be cached and we get incorrect data.
if (directory == null || !File.Exists(directory.FullName))
{
return null;
}