• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/volume/base.php
  • Класс: Bitrix\Crm\Volume\Base
  • Вызов: Base::clearDiskFiles
protected function clearDiskFiles(Disk\Folder $folder, $filter = array())
{
	if (!self::isModuleAvailable('disk'))
	{
		return false;
	}
	if (!($folder instanceof Disk\Folder))
	{
		return false;
	}

	$filter['=STORAGE_ID'] = $folder->getStorageId();
	$filter['=PATH_CHILD.PARENT_ID'] = $folder->getId();
	$filter['=TYPE'] = Disk\Internals\ObjectTable::TYPE_FILE;

	if ($this->getProcessOffset() > 0)
	{
		$filter['>ID'] = $this->getProcessOffset();
	}

	$objectList = Disk\Internals\ObjectTable::getList(array(
		'filter' => $filter,
		'order' => array(
			'PATH_CHILD.DEPTH_LEVEL' => 'DESC',
			'ID' => 'ASC',
		),
		'limit' => static::MAX_FILE_PER_INTERACTION,
	));

	$success = true;

	foreach ($objectList as $row)
	{
		$file = Disk\BaseObject::buildFromArray($row);

		if($file instanceof Disk\File)
		{
			/** @var Disk\File $file */
			$securityContext = $this->getDiskSecurityContext($file);
			if($file->canDelete($securityContext))
			{
				if ($this->deleteDiskFile($file))
				{
					$this->incrementDroppedFileCount();
				}
				else
				{
					//$this->collectError(new Error('Deletion failed with file #'. $file->getId(), self::ERROR_DELETION_FAILED));
					$this->incrementFailCount();
				}
			}
			else
			{
				$this->collectError(new Error('Access denied to file #'. $file->getId(), self::ERROR_PERMISSION_DENIED));
				$this->incrementFailCount();
			}
		}

		$this->setProcessOffset($row['ID']);

		if ($this->hasTimeLimitReached())
		{
			$success = false;
			break;
		}
	}

	return $success;
}