rework static files server

This commit is contained in:
rootdarkarchon
2022-12-20 14:20:24 +01:00
parent ea19231851
commit 25aa01c819
12 changed files with 315 additions and 224 deletions

View File

@@ -0,0 +1,27 @@
namespace MareSynchronosStaticFilesServer;
public static class FilePathUtil
{
public static FileInfo? GetFileInfoForHash(string basePath, string hash)
{
FileInfo fi = new(Path.Combine(basePath, hash[0].ToString(), hash));
if (!fi.Exists)
{
fi = new FileInfo(Path.Combine(basePath, hash));
if (!fi.Exists)
{
return null;
}
}
return fi;
}
public static string GetFilePath(string basePath, string hash)
{
var dirPath = Path.Combine(basePath, hash[0].ToString());
var path = Path.Combine(dirPath, hash);
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
return path;
}
}