mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 18:04:16 +01:00
reimplment ReadAsync for BlockFileDataStream/SubStream
This commit is contained in:
parent
7acd36bb79
commit
c80848fa2e
5 changed files with 128 additions and 77 deletions
|
|
@ -36,9 +36,9 @@ public class CacheController : ControllerBase
|
|||
long requestSize = 0;
|
||||
List<BlockFileDataSubstream> substreams = new();
|
||||
|
||||
foreach (var file in request.FileIds)
|
||||
foreach (var fileHash in request.FileIds)
|
||||
{
|
||||
var fs = await _cachedFileProvider.GetAndDownloadFileStream(file);
|
||||
var fs = await _cachedFileProvider.DownloadAndGetLocalFileInfo(fileHash).ConfigureAwait(false);
|
||||
if (fs == null) continue;
|
||||
|
||||
substreams.Add(new(fs));
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ public class DistributionController : ControllerBase
|
|||
|
||||
[HttpGet(MareFiles.Distribution_Get)]
|
||||
[Authorize(Policy = "Internal")]
|
||||
public async Task<IActionResult> GetFile(string file)
|
||||
public async Task<IActionResult> GetFile(string fileHash)
|
||||
{
|
||||
_logger.LogInformation($"GetFile:{MareUser}:{file}");
|
||||
_logger.LogInformation($"GetFile:{MareUser}:{fileHash}");
|
||||
|
||||
var fs = await _cachedFileProvider.GetAndDownloadFileStream(file);
|
||||
var fs = await _cachedFileProvider.DownloadAndGetLocalFileInfo(fileHash);
|
||||
if (fs == null) return NotFound();
|
||||
|
||||
return File(fs, "application/octet-stream");
|
||||
return PhysicalFile(fs.FullName, "application/octet-stream");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue