/** * Implements the _finalize() abstract method * */ protected function _finalize() { static $addedExtraSQL = false; // This makes sure that we don't re-add the extra SQL if the archiver needed more time // to include our file in the archive... if(!$addedExtraSQL) { AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Adding any extra SQL statements imposed by the filters"); $filters =& AEFactory::getFilters(); $this->writeline( $filters->getExtraSQL($this->databaseRoot) ); } // Close the file pointer (otherwise the SQL file is left behind) $this->closeFile(); // If we are not just doing a main db only backup, add the SQL file to the archive $finished = true; $configuration =& AEFactory::getConfiguration(); if( AEUtilScripting::getScriptingParameter('db.saveasname','normal') != 'output' ) { $archiver =& AEFactory::getArchiverEngine(); $configuration =& AEFactory::getConfiguration(); if( $configuration->get('volatile.engine.archiver.processingfile',false) ) { // We had already started archiving the db file, but it needs more time AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Continuing adding the SQL dump to the archive"); $archiver->addFile(null,null,null); if($this->getError()) return; $finished = !$configuration->get('volatile.engine.archiver.processingfile',false); } else { // We have to add the dump file to the archive AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Adding the SQL dump to the archive"); $archiver->addFileRenamed( $this->tempFile, $this->saveAsName ); if($this->getError()) return; $finished = !$configuration->get('volatile.engine.archiver.processingfile',false); } } else { // We just have to move the dump file to its final destination AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Moving the SQL dump to its final location"); $result = AEPlatform::move( $this->tempFile, $this->saveAsName ); if(!$result) { $this->setError('Could not move the SQL dump to its final location'); } } // Make sure that if the archiver needs more time to process the file we can supply it if($finished) { AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Removing temporary file"); AEUtilTempfiles::unregisterAndDeleteTempFile( $this->tempFile, true ); if($this->getError()) return; $this->setState('finished'); } }