mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 19:27:21 +01:00
bugfix
This commit is contained in:
parent
3ed4ef454c
commit
91813bb67f
2 changed files with 12 additions and 7 deletions
|
|
@ -72,7 +72,6 @@ public class ServerFilesController : ControllerBase
|
||||||
[HttpGet(MareFiles.ServerFiles_GetSizes)]
|
[HttpGet(MareFiles.ServerFiles_GetSizes)]
|
||||||
public async Task<IActionResult> FilesGetSizes([FromBody] List<string> hashes)
|
public async Task<IActionResult> FilesGetSizes([FromBody] List<string> hashes)
|
||||||
{
|
{
|
||||||
var allFiles = await _mareDbContext.Files.Where(f => hashes.Contains(f.Hash)).ToListAsync().ConfigureAwait(false);
|
|
||||||
var forbiddenFiles = await _mareDbContext.ForbiddenUploadEntries.
|
var forbiddenFiles = await _mareDbContext.ForbiddenUploadEntries.
|
||||||
Where(f => hashes.Contains(f.Hash)).ToListAsync().ConfigureAwait(false);
|
Where(f => hashes.Contains(f.Hash)).ToListAsync().ConfigureAwait(false);
|
||||||
List<DownloadFileDto> response = new();
|
List<DownloadFileDto> response = new();
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,17 @@
|
||||||
namespace MareSynchronosStaticFilesServer.Utils;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
public static class FilePathUtil
|
namespace MareSynchronosStaticFilesServer.Utils;
|
||||||
|
|
||||||
|
public static partial class FilePathUtil
|
||||||
{
|
{
|
||||||
public static FileInfo GetFileInfoForHash(string basePath, string hash)
|
public static FileInfo GetFileInfoForHash(string basePath, string hash)
|
||||||
{
|
{
|
||||||
FileInfo fi = new(Path.Combine(basePath, hash[0].ToString(), hash));
|
if (hash.Length != 40 || !hash.All(char.IsAsciiLetterOrDigit)) throw new InvalidOperationException();
|
||||||
|
|
||||||
|
FileInfo fi = new(Path.Join(basePath, hash[0].ToString(), hash));
|
||||||
if (!fi.Exists)
|
if (!fi.Exists)
|
||||||
{
|
{
|
||||||
fi = new FileInfo(Path.Combine(basePath, hash));
|
fi = new FileInfo(Path.Join(basePath, hash));
|
||||||
if (!fi.Exists)
|
if (!fi.Exists)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -19,8 +23,10 @@ public static class FilePathUtil
|
||||||
|
|
||||||
public static string GetFilePath(string basePath, string hash)
|
public static string GetFilePath(string basePath, string hash)
|
||||||
{
|
{
|
||||||
var dirPath = Path.Combine(basePath, hash[0].ToString());
|
if (hash.Length != 40 || !hash.All(char.IsAsciiLetterOrDigit)) throw new InvalidOperationException();
|
||||||
var path = Path.Combine(dirPath, hash);
|
|
||||||
|
var dirPath = Path.Join(basePath, hash[0].ToString());
|
||||||
|
var path = Path.Join(dirPath, hash);
|
||||||
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue