mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-10 09:23:11 +00:00
42 lines
996 B
C#
42 lines
996 B
C#
using Logging;
|
|
|
|
namespace AutoClient.Modes.FolderStore
|
|
{
|
|
public class QuotaCheck
|
|
{
|
|
private readonly ILog log;
|
|
private readonly string filepath;
|
|
private readonly CodexWrapper instance;
|
|
|
|
public QuotaCheck(ILog log, string filepath, CodexWrapper instance)
|
|
{
|
|
this.log = log;
|
|
this.filepath = filepath;
|
|
this.instance = instance;
|
|
}
|
|
|
|
public bool IsLocalQuotaAvailable()
|
|
{
|
|
try
|
|
{
|
|
return CheckQuota();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
log.Error("Failed to check quota: " + exc);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
private bool CheckQuota()
|
|
{
|
|
var info = new FileInfo(filepath);
|
|
var fileSize = info.Length;
|
|
var padded = fileSize * 1.1;
|
|
|
|
var space = instance.Node.Space();
|
|
return space.FreeBytes > padded;
|
|
}
|
|
}
|
|
}
|