mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 17:57: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)]
|
||||
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.
|
||||
Where(f => hashes.Contains(f.Hash)).ToListAsync().ConfigureAwait(false);
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
fi = new FileInfo(Path.Combine(basePath, hash));
|
||||
fi = new FileInfo(Path.Join(basePath, hash));
|
||||
if (!fi.Exists)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -19,8 +23,10 @@ public static class FilePathUtil
|
|||
|
||||
public static string GetFilePath(string basePath, string hash)
|
||||
{
|
||||
var dirPath = Path.Combine(basePath, hash[0].ToString());
|
||||
var path = Path.Combine(dirPath, hash);
|
||||
if (hash.Length != 40 || !hash.All(char.IsAsciiLetterOrDigit)) throw new InvalidOperationException();
|
||||
|
||||
var dirPath = Path.Join(basePath, hash[0].ToString());
|
||||
var path = Path.Join(dirPath, hash);
|
||||
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
||||
return path;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue