lib/private/Files/Stream/Encryption.php
/**
	 * write block to file
	 * @param string $positionPrefix
	 */
write block to file
@param string $positionPrefix
write block to file @param string $positionPrefix
protected function flush($positionPrefix = '') {
		if ($this->writeFlag) {
			$position = (int)floor($this->position/$this->unencryptedBlockSize);
			$encrypted = $this->encryptionModule->encrypt($this->cache, $position . $positionPrefix);
			$bytesWritten = parent::stream_write($encrypted);
			$this->writeFlag = false;
			$completeBlocksInFile=(int)floor($this->unencryptedSize/$this->unencryptedBlockSize);
			if ($completeBlocksInFile === (int)floor($this->position/$this->unencryptedBlockSize)) {
				$this->size = $this->util->getBlockSize() * $completeBlocksInFile;
				$this->size += $bytesWritten;
				$this->size += $this->headerSize;
			}
		}
		$this->cache = '';
	}
protected function flush ( $ positionPrefix = '' ) { if ( $ this -> writeFlag ) { $ position = ( int ) floor ( $ this -> position / $ this -> unencryptedBlockSize ) ; $ encrypted = $ this -> encryptionModule -> encrypt ( $ this -> cache , $ position . $ positionPrefix ) ; $ bytesWritten = parent :: stream_write ( $ encrypted ) ; $ this -> writeFlag = false ; $ completeBlocksInFile = ( int ) floor ( $ this -> unencryptedSize / $ this -> unencryptedBlockSize ) ; if ( $ completeBlocksInFile === ( int ) floor ( $ this -> position / $ this -> unencryptedBlockSize ) ) { $ this -> size = $ this -> util -> getBlockSize ( ) * $ completeBlocksInFile ; $ this -> size += $ bytesWritten ; $ this -> size += $ this -> headerSize ; } } $ this -> cache = '' ; }
write block to file
 @param string $positionPrefix
write block to file @param string $positionPrefix
// write to disk only when writeFlag was set to 1 // Disable the file proxies so that encryption is not // automatically attempted when the file is written to disk - // we are handling that separately here and we don't want to // get into an infinite loop // Check whether the write concerns the last block // If so then update the encrypted filesize // Note that the unencrypted pointer and filesize are NOT yet updated when flush() is called // We recalculate the encrypted filesize as we do not know the context of calling flush() // always empty the cache (otherwise readCache() will not fill it with the new block)