mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-05 23:13:08 +00:00
Regenerates unique data for new checks
This commit is contained in:
parent
c630d4c81e
commit
9446671b18
@ -37,7 +37,7 @@ namespace BiblioTech.CodexChecking
|
||||
public async Task StartDownloadCheck(ICheckResponseHandler handler, ulong userId)
|
||||
{
|
||||
var check = repo.GetOrCreate(userId).DownloadCheck;
|
||||
if (string.IsNullOrEmpty(check.UniqueData))
|
||||
if (IsUniqueDataStale(check))
|
||||
{
|
||||
check.UniqueData = GenerateUniqueData();
|
||||
repo.SaveChanges();
|
||||
@ -69,7 +69,7 @@ namespace BiblioTech.CodexChecking
|
||||
public async Task StartUploadCheck(ICheckResponseHandler handler, ulong userId)
|
||||
{
|
||||
var check = repo.GetOrCreate(userId).UploadCheck;
|
||||
if (string.IsNullOrEmpty(check.UniqueData))
|
||||
if (IsUniqueDataStale(check))
|
||||
{
|
||||
check.UniqueData = GenerateUniqueData();
|
||||
repo.SaveChanges();
|
||||
@ -111,6 +111,15 @@ namespace BiblioTech.CodexChecking
|
||||
return $"{RandomBusyMessage.Get().Substring(5)}{RandomUtils.GenerateRandomString(12)}";
|
||||
}
|
||||
|
||||
private bool IsUniqueDataStale(TransferCheck check)
|
||||
{
|
||||
var expiry = DateTime.UtcNow - TimeSpan.FromMinutes(10.0);
|
||||
|
||||
return
|
||||
string.IsNullOrEmpty(check.UniqueData) ||
|
||||
check.CompletedUtc < expiry;
|
||||
}
|
||||
|
||||
private string UploadData(string uniqueData)
|
||||
{
|
||||
var filePath = Path.Combine(config.ChecksDataPath, Guid.NewGuid().ToString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user