• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/file.php
  • Класс: CFile
  • Вызов: CFile::DeleteHashAgent
static function DeleteHashAgent()
{
	global $DB;

	$res = $DB->Query("select distinct h1.FILE_ID
		FROM b_file_hash h1, b_file_hash h2
		WHERE h1.FILE_ID > h2.FILE_ID
			AND h1.FILE_SIZE = h2.FILE_SIZE
			AND h1.FILE_HASH = h2.FILE_HASH
		limit 10000
	");

	$delete = [];
	while ($ar = $res->Fetch())
	{
		$delete[] = $ar['FILE_ID'];
	}

	if (!empty($delete))
	{
		$DB->Query("DELETE FROM b_file_hash WHERE FILE_ID IN (" . implode(',', $delete) . ")");

		return __METHOD__ . '();';
	}

	return '';
}