reimplment ReadAsync for BlockFileDataStream/SubStream

This commit is contained in:
Stanley Dimant
2024-11-04 11:51:13 +01:00
parent 7acd36bb79
commit c80848fa2e
5 changed files with 128 additions and 77 deletions

View File

@@ -167,7 +167,7 @@ public sealed class CachedFileProvider : IDisposable
_downloadSemaphore.Release();
}
public FileStream? GetLocalFileStream(string hash)
public FileInfo? GetLocalFilePath(string hash)
{
var fi = FilePathUtil.GetFileInfoForHash(_hotStoragePath, hash);
if (fi == null) return null;
@@ -176,10 +176,10 @@ public sealed class CachedFileProvider : IDisposable
_fileStatisticsService.LogFile(hash, fi.Length);
return new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Inheritable | FileShare.Read);
return new FileInfo(fi.FullName);
}
public async Task<FileStream?> GetAndDownloadFileStream(string hash)
public async Task<FileInfo?> DownloadAndGetLocalFileInfo(string hash)
{
await DownloadFileWhenRequired(hash).ConfigureAwait(false);
@@ -203,7 +203,7 @@ public sealed class CachedFileProvider : IDisposable
}
}
return GetLocalFileStream(hash);
return GetLocalFilePath(hash);
}
public bool AnyFilesDownloading(List<string> hashes)