move GetFileSize to database

This commit is contained in:
rootdarkarchon
2022-12-28 04:50:37 +01:00
parent de2defe692
commit 31550b0aeb
8 changed files with 572 additions and 40 deletions

View File

@@ -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);
}
}