mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 18:44:14 +01:00
move GetFileSize to database
This commit is contained in:
parent
de2defe692
commit
31550b0aeb
8 changed files with 572 additions and 40 deletions
|
|
@ -46,6 +46,7 @@ public class GrpcFileService : FileService.FileServiceBase
|
|||
|
||||
var fileSize = new FileInfo(filePath).Length;
|
||||
file.Uploaded = true;
|
||||
file.Size = fileSize;
|
||||
|
||||
await _mareDbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
|
||||
|
|
@ -96,16 +97,4 @@ public class GrpcFileService : FileService.FileServiceBase
|
|||
await _mareDbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
return new Empty();
|
||||
}
|
||||
|
||||
public override Task<FileSizeResponse> GetFileSizes(FileSizeRequest request, ServerCallContext context)
|
||||
{
|
||||
FileSizeResponse response = new();
|
||||
foreach (var hash in request.Hash.Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
FileInfo? fi = FilePathUtil.GetFileInfoForHash(_basePath, hash);
|
||||
response.HashToFileSize.Add(hash, fi?.Length ?? 0);
|
||||
}
|
||||
|
||||
return Task.FromResult(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue