• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/backup.php
  • Класс: CloudDownload
  • Вызов: CloudDownload::Scan
function Scan($path)
{
	$this->path = $path;

	if ($arCloudFiles = CBackup::GetBucketFileList($this->id, $path))
	{
		foreach($arCloudFiles['file'] as $k=>$file)
		{
			if ($this->last_bucket_path)
			{
				if ($path.'/'.$file == $this->last_bucket_path)
					$this->last_bucket_path = '';
				else
					continue;
			}

			$name = $this->path = $path.'/'.$file;
			if (!haveTime()) // Сохраняется путь файла, который еще предстоит сохранить, TODO: пошаговое скачивание больших файлов
				return false;

			$HTTP = new CHTTP;
			if ($HTTP->Download($this->obBucket->GetFileSRC(array("URN" => $name)), DOCUMENT_ROOT.BX_ROOT.'/backup/clouds/'.$this->id.$name))
			{
				$this->download_size += $arCloudFiles['file_size'][$k];
				$this->download_cnt++;
			}
			else
				$this->arSkipped[] = $name;
		}
	}

	foreach($arCloudFiles['dir'] as $dir)
	{
		if ($this->last_bucket_path)
		{
			if ($path.'/'.$dir == $this->last_bucket_path)
				$this->last_bucket_path = '';
			elseif (mb_strpos($this->last_bucket_path, $path.'/'.$dir) !== 0)
				continue;
		}

		if ($path.'/'.$dir == '/bitrix/backup')
			continue;

		if ($path.'/'.$dir == '/tmp')
			continue;

		if (!$this->Scan($path.'/'.$dir)) // partial
			return false;
	}

	return true;
}