Merge pull request #2992 from FlorinPeter/files_encryption

fix for trashbin
This commit is contained in:
FlorinPeter 2013-04-20 05:35:29 -07:00
commit 9a0b73070c
2 changed files with 40 additions and 3 deletions

View File

@ -237,6 +237,11 @@ class Proxy extends \OC_FileProxy {
*/
public function preUnlink( $path ) {
// let the trashbin handle this
if ( \OCP\App::isEnabled('files_trashbin') ) {
return true;
}
$path = Keymanager::fixPartialFilePath( $path );
// Disable encryption proxy to prevent recursive calls
@ -417,9 +422,41 @@ class Proxy extends \OC_FileProxy {
public function postFileSize( $path, $size ) {
if ( Crypt::isCatfileContent( $path ) ) {
// Reformat path for use with OC_FSV
$path_split = explode( '/', $path );
$path_f = implode( '/', array_slice( $path_split, 3 ) );
$cached = \OC\Files\Filesystem::getFileInfo( $path, '' );
if ( Crypt::isEncryptedMeta( $path_f ) ) {
// Disable encryption proxy to prevent recursive calls
\OC_FileProxy::$enabled = false;
// get file info
$cached = \OC\Files\Filesystem::getFileInfo( $path_f, '' );
// calculate last chunk nr
$lastChunckNr = floor( $size / 8192);
// open stream
$result = fopen( 'crypt://'.$path_f, "r" );
// calculate last chunk position
$lastChunckPos = ( $lastChunckNr * 8192 );
// seek to end
fseek( $result, $lastChunckPos );
// get the content of the last chunck
$lastChunkContent = fgets( $result );
// calc the real filesize with the size of the last chunk
$realSize = ( ( $lastChunckNr * 6126 ) + strlen( $lastChunkContent ) );
// enable proxy
\OC_FileProxy::$enabled = true;
// set the size
$cached['size'] = $realSize;
return $cached['size'];

View File

@ -513,7 +513,7 @@ class Stream {
and $this->meta['mode']!='rb'
) {
\OC\Files\Filesystem::putFileInfo( $this->path, array( 'encrypted' => true, 'size' => $this->size ), '' );
\OC\Files\Filesystem::putFileInfo( $this->relPath, array( 'encrypted' => true, 'size' => $this->size ), '' );
}