mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 22:17:22 +01:00
rework static files server
This commit is contained in:
parent
ea19231851
commit
25aa01c819
12 changed files with 315 additions and 224 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue