/**
  * @return array
  */
 protected function commitFile()
 {
     $filename = CTempFile::GetFileName(uniqid('_wd'));
     $nameToSavedFile = $this->getNameToSavedFile($this->getWebdav()->arParams['element_name']);
     CheckDirPath($filename);
     $doc = $this->getDocHandler()->downloadFile(array('id' => $this->getFileId(), 'mimeType' => $this->getWebdav()->get_mime_type($nameToSavedFile)));
     if (!$doc['content']) {
         return array('status' => 'error');
     }
     file_put_contents($filename, $doc['content']);
     $runRename = $nameToSavedFile != $this->getWebdav()->arParams['element_name'];
     $oldName = $this->getWebdav()->arParams['element_name'];
     $options = array('new' => false, 'FILE_NAME' => $nameToSavedFile, 'NAME' => $nameToSavedFile, 'ELEMENT_ID' => $this->getWebdav()->arParams['item_id'], 'TMP_FILE' => $filename);
     global $DB;
     $DB->startTransaction();
     if (!$this->getWebdav()->put_commit($options)) {
         $DB->rollback();
         $response = array('status' => 'error');
     } else {
         $DB->commit();
         $webdav = $this->getWebdav();
         $response = array('status' => 'success');
         $response['elementId'] = $webdav->arParams['element_array']['ID'];
         //this is info for comment. And fileId == false,as this is last version and not save in BPhistory
         $response['cid'] = $this->generateCidForFile($response['elementId']);
         $response['serialize'] = CUserTypeWebdavElementHistory::genData(array('ib' => $webdav->IBLOCK_ID, 'ib_code' => $webdav->arParams['element_array']['IBLOCK_CODE'], 'id' => $response['elementId']), array('t_vers' => empty($options['THROUGH_VERSION']) ? 0 : $options['THROUGH_VERSION']));
         if ($runRename) {
             CWebDavTools::clearByTag('webdav_element_internal_' . $webdav->arParams['element_array']['ID']);
             $response['newName'] = $options['NAME'];
             $response['oldName'] = $oldName;
         }
     }
     @unlink($filename);
     return $response;
 }