• Модуль: clouds
  • Путь к файлу: ~/bitrix/modules/clouds/classes/general/temp_file.php
  • Класс: CCloudTempFile
  • Вызов: CCloudTempFile::cleanupFilesLock
static function cleanupFilesLock($lock = true)
{
	if (!self::$my_pid)
	{
		self::$my_pid = md5(mt_rand());
	}

	$obCacheLock = null;
	$cache_ttl = 300;
	$uniq_str = 'cleanupFiles';
	$init_dir = 'clouds';

	$obCacheLock = new CPHPCache();
	if ($lock)
	{
		if ($obCacheLock->InitCache($cache_ttl, $uniq_str, $init_dir))
		{
			$vars = $obCacheLock->GetVars();
			if (self::$my_pid !== $vars['pid'])
			{
				return false; //There is other cleaning process
			}
		}
		elseif ($obCacheLock->StartDataCache())
		{
			$obCacheLock->EndDataCache(array('pid' => self::$my_pid));
		}
	}
	else
	{
		$obCacheLock->Clean($uniq_str, $init_dir);
	}

	return true;
}