BatchLimits
using Relativity.DataTransfer.Nodes;
using Relativity.Transfer.Enumeration.Interfaces;
namespace Relativity.Transfer.Enumeration.Batches
{
internal class BatchLimits : IBatchLimits
{
private readonly int _maxPathsNumber;
private readonly long _maxBytesSize;
public BatchLimits()
: this(GlobalSettings.Instance.MaxFilesPerBatch, GlobalSettings.Instance.MaxBytesPerBatch)
{
}
public BatchLimits(int maxPathsNumber, long maxBytesSize)
{
_maxPathsNumber = maxPathsNumber;
_maxBytesSize = maxBytesSize;
}
public bool FitsInBatch(INode node, BatchNodesBuffer buffer)
{
long num = (node as IFile)?.Size ?? 0;
bool num2 = buffer.Count() >= _maxPathsNumber;
bool flag = buffer.CurrentBatchBytesSize + num > _maxBytesSize;
return !(num2 | flag);
}
}
}