• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/controller/export.php
  • Класс: BitrixMainControllerExport
  • Вызов: Export::dispatcherAction
public function dispatcherAction()
{
	// can we use cloud
	if ($this->isCloudAvailable && $this->useCloud === null)
	{
		if (
			($this->bucketId < 0) &&
			($this->totalItems > 0) &&
			($this->processedItems > 0) &&
			($this->fileName !== '') &&
			($this->getSizeTempFile() > 0) &&
			(($this->getSizeTempFile() > $this->cloudMinChunkSize) || $this->isExportCompleted)
		)
		{
			if ($this->isExportCompleted)
			{
				$predictedFileSize = $this->getSizeTempFile();
			}
			else
			{
				$predictedFileSize = round($this->getSizeTempFile() * ceil($this->totalItems / $this->processedItems) * 1.5);
			}
			// check cloud bucket rules
			if ($this->findInitBucket(array('fileSize' => $predictedFileSize, 'fileName' => $this->fileName)) === true)
			{
				// allow
				$this->useCloud = true;
			}
			else
			{
				// deny
				$this->useCloud = false;
				$this->isCloudAvailable = false;
			}
		}
	}

	if ($this->isNewProcess)
	{
		// start export
		$this->stepCount = 0;
		$this->timeStart = time();
		$nextAction = self::ACTION_EXPORT;
	}
	elseif ($this->isBitrix24)
	{
		if ($this->isExportCompleted && !$this->isUploadFinished)
		{
			// upload last chunk
			$nextAction = self::ACTION_UPLOAD;
		}
		elseif ($this->isExportCompleted && $this->isUploadFinished)
		{
			// purge cloud and finish
			$nextAction = self::ACTION_PURGE;
		}
		elseif ($this->getSizeTempFile() > $this->cloudMinChunkSize)
		{
			// upload chunk
			$nextAction = self::ACTION_UPLOAD;
		}
		else
		{
			// continue export into temporally file
			$nextAction = self::ACTION_EXPORT;
		}
	}
	else
	{
		// non b24
		if ($this->isExportCompleted && ($this->useCloud === true) && !$this->isUploadFinished)
		{
			// upload last chunk
			$nextAction = self::ACTION_UPLOAD;
		}
		elseif ($this->isExportCompleted && ($this->useCloud === true) && $this->isUploadFinished)
		{
			// purge cloud and finish
			$nextAction = self::ACTION_PURGE;
		}
		elseif ($this->isExportCompleted && ($this->useCloud === false || $this->useCloud === null))
		{
			// completed
			$nextAction = self::ACTION_FINISH;
		}
		elseif (($this->useCloud === true) && ($this->getSizeTempFile() > $this->cloudMinChunkSize))
		{
			// upload chunk
			$nextAction = self::ACTION_UPLOAD;
		}
		else
		{
			// continue export into temporally file
			$nextAction = self::ACTION_EXPORT;
		}
	}

	if ($nextAction === self::ACTION_PURGE)
	{
		return $this->purgeAction();
	}
	if ($nextAction === self::ACTION_EXPORT)
	{
		$this->stepCount ++;
		return $this->exportAction();
	}
	if ($nextAction === self::ACTION_UPLOAD)
	{
		$this->stepCount ++;
		return $this->uploadAction();
	}
	if ($nextAction === self::ACTION_FINISH)
	{
		return $this->finishAction();
	}

	return $this->cancelAction();
}