- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/volume/storage/trashcan.php
- Класс: BitrixDiskVolumeStorageTrashCan
- Вызов: TrashCan::recalculatePercent
public function recalculatePercent($totalSizeIndicator = '\Bitrix\Disk\Volume\Module\Disk', $excludeSizeIndicator = null): self
{
if (is_string($totalSizeIndicator) && !empty($totalSizeIndicator) && class_exists($totalSizeIndicator))
{
/** @var VolumeModuleDisk $totalSizeIndicator */
$totalSizeIndicator = new $totalSizeIndicator();
}
if (!($totalSizeIndicator instanceof VolumeIVolumeIndicator))
{
throw new ArgumentException('Wrong parameter totalSizeIndicator');
}
$totalSizeIndicator->setOwner($this->getOwner());
$totalSizeIndicator->loadTotals();
$total = $totalSizeIndicator->getTotalSize() + $totalSizeIndicator->getPreviewSize();
if ($total > 0)
{
$filter = $this->getFilter(
[
'=INDICATOR_TYPE' => static::className(),
'=OWNER_ID' => $this->getOwner(),
'>FILE_COUNT' => 0,
],
VolumeTable::getEntity()
);
$where = Query::buildFilterSql(VolumeTable::getEntity(), $filter);
$tableName = VolumeTable::getTableName();
$sql = 'UPDATE '.$tableName.' SET PERCENT = ROUND((FILE_SIZE + PREVIEW_SIZE) * 100 / '.$total.', 4) WHERE '.$where;
$connection = Application::getConnection();
if ($connection->lock(self::$lockName, self::$lockTimeout))
{
$connection->queryExecute($sql);
$connection->unlock(self::$lockName);
}
}
return $this;
}