diff options
-rwxr-xr-x | apps/files_encryption/lib/keymanager.php | 1 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 3 | ||||
-rw-r--r-- | apps/files_encryption/lib/stream.php | 3 | ||||
-rw-r--r-- | apps/files_encryption/lib/util.php | 21 | ||||
-rw-r--r-- | apps/files_external/lib/sftp.php | 14 | ||||
-rw-r--r-- | apps/files_external/lib/webdav.php | 4 | ||||
-rw-r--r-- | lib/private/connector/sabre/filesplugin.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/common.php | 26 | ||||
-rw-r--r-- | lib/private/files/storage/commontest.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/local.php | 8 | ||||
-rw-r--r-- | lib/private/files/storage/mappedlocal.php | 8 | ||||
-rw-r--r-- | version.php | 4 |
12 files changed, 36 insertions, 60 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index b207b1437ba..4695673a48b 100755 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -181,6 +181,7 @@ class Keymanager { */ public static function getFileKey(\OC_FilesystemView $view, $util, $filePath) { + list($owner, $filename) = $util->getUidAndFilename($filePath); $filename = Helper::stripPartialFileExtension($filename); $filePath_f = ltrim($filename, '/'); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index f7253b4591b..b0b2b62aa1b 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -350,7 +350,10 @@ class Proxy extends \OC_FileProxy { $fileInfo = false; // get file info from database/cache if not .part file if (!Helper::isPartialFilePath($path)) { + $proxyState = \OC_FileProxy::$enabled; + \OC_FileProxy::$enabled = false; $fileInfo = $view->getFileInfo($path); + \OC_FileProxy::$enabled = $proxyState; } // if file is encrypted return real file size diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php index 409c6ff6273..4b0156e661e 100644 --- a/apps/files_encryption/lib/stream.php +++ b/apps/files_encryption/lib/stream.php @@ -497,7 +497,8 @@ class Stream { if ( $this->meta['mode'] !== 'r' && $this->meta['mode'] !== 'rb' && - $this->size > 0 + $this->size > 0 && + $this->unencryptedSize > 0 ) { // only write keyfiles if it was a new file diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 2dd4fd9c163..a9468e34d41 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -455,22 +455,19 @@ class Util { */ public function isEncryptedPath($path) { - // Disable encryption proxy so data retrieved is in its - // original form - $proxyStatus = \OC_FileProxy::$enabled; - \OC_FileProxy::$enabled = false; + $relPath = Helper::getPathToRealFile($path); - // we only need 24 byte from the last chunk - $data = ''; - $handle = $this->view->fopen($path, 'r'); - if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) { - $data = fgets($handle); + if ($relPath === false) { + $relPath = Helper::stripUserFilesPath($path); } - // re-enable proxy - \OC_FileProxy::$enabled = $proxyStatus; + $fileKey = Keymanager::getFileKey($this->view, $relPath); - return Crypt::isCatfileContent($data); + if ($fileKey === false) { + return false; + } + + return true; } diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index fb1ecd54635..7c5aed5aa06 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -94,15 +94,17 @@ class SFTP extends \OC\Files\Storage\Common { private function writeHostKeys($keys) { try { $keyPath = $this->hostKeysPath(); - $fp = fopen($keyPath, 'w'); - foreach ($keys as $host => $key) { - fwrite($fp, $host . '::' . $key . "\n"); + if ($keyPath && file_exists($keyPath)) { + $fp = fopen($keyPath, 'w'); + foreach ($keys as $host => $key) { + fwrite($fp, $host . '::' . $key . "\n"); + } + fclose($fp); + return true; } - fclose($fp); - return true; } catch (\Exception $e) { - return false; } + return false; } private function readHostKeys() { diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 66920fc9f64..9ee7f555285 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -268,7 +268,7 @@ class DAV extends \OC\Files\Storage\Common{ public function rename($path1, $path2) { $this->init(); $path1=$this->cleanPath($path1); - $path2=$this->root.$this->cleanPath($path2); + $path2=$this->createBaseUri().$this->cleanPath($path2); try { $this->client->request('MOVE', $path1, null, array('Destination'=>$path2)); return true; @@ -280,7 +280,7 @@ class DAV extends \OC\Files\Storage\Common{ public function copy($path1, $path2) { $this->init(); $path1=$this->cleanPath($path1); - $path2=$this->root.$this->cleanPath($path2); + $path2=$this->createBaseUri().$this->cleanPath($path2); try { $this->client->request('COPY', $path1, null, array('Destination'=>$path2)); return true; diff --git a/lib/private/connector/sabre/filesplugin.php b/lib/private/connector/sabre/filesplugin.php index 89444cb8d18..1c80ebe8044 100644 --- a/lib/private/connector/sabre/filesplugin.php +++ b/lib/private/connector/sabre/filesplugin.php @@ -78,6 +78,8 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin * @throws Sabre_DAV_Exception_BadRequest */ public function sendFileIdHeader($filePath, Sabre_DAV_INode $node = null) { + // we get the node for the given $filePath here because in case of afterCreateFile $node is the parent folder + $node = $this->server->tree->getNodeForPath($filePath); if ($node instanceof OC_Connector_Sabre_Node) { $fileId = $node->getFileId(); if (!is_null($fileId)) { diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 3943d667c35..f99bbc9ae5e 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -142,7 +142,7 @@ abstract class Common implements \OC\Files\Storage\Storage { return false; } else { $directoryHandle = $this->opendir($directory); - if(is_resource($directoryHandle)) { + if (is_resource($directoryHandle)) { while (($contents = readdir($directoryHandle)) !== false) { if (!\OC\Files\Filesystem::isIgnoredDir($contents)) { $path = $directory . '/' . $contents; @@ -165,27 +165,13 @@ abstract class Common implements \OC\Files\Storage\Storage { } public function getMimeType($path) { - if (!$this->file_exists($path)) { - return false; - } if ($this->is_dir($path)) { return 'httpd/unix-directory'; - } - $source = $this->fopen($path, 'r'); - if (!$source) { - return false; - } - $head = fread($source, 8192); //8kb should suffice to determine a mimetype - if ($pos = strrpos($path, '.')) { - $extension = substr($path, $pos); + } elseif ($this->file_exists($path)) { + return \OC_Helper::getFileNameMimeType($path); } else { - $extension = ''; + return false; } - $tmpFile = \OC_Helper::tmpFile($extension); - file_put_contents($tmpFile, $head); - $mime = \OC_Helper::getMimeType($tmpFile); - unlink($tmpFile); - return $mime; } public function hash($type, $path, $raw = false) { @@ -227,7 +213,7 @@ abstract class Common implements \OC\Files\Storage\Storage { private function addLocalFolder($path, $target) { $dh = $this->opendir($path); - if(is_resource($dh)) { + if (is_resource($dh)) { while (($file = readdir($dh)) !== false) { if ($file !== '.' and $file !== '..') { if ($this->is_dir($path . '/' . $file)) { @@ -298,7 +284,7 @@ abstract class Common implements \OC\Files\Storage\Storage { return $this->watcher; } - public function getStorageCache(){ + public function getStorageCache() { if (!isset($this->storageCache)) { $this->storageCache = new \OC\Files\Cache\Storage($this); } diff --git a/lib/private/files/storage/commontest.php b/lib/private/files/storage/commontest.php index c3f1eb31955..2394b14a82f 100644 --- a/lib/private/files/storage/commontest.php +++ b/lib/private/files/storage/commontest.php @@ -54,7 +54,7 @@ class CommonTest extends \OC\Files\Storage\Common{ return $this->storage->stat($path); } public function filetype($path) { - return $this->storage->filetype($path); + return @$this->storage->filetype($path); } public function isReadable($path) { return $this->storage->isReadable($path); diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 5209fabc30a..02e8df4af4e 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -203,14 +203,6 @@ if (\OC_Util::runningOnWindows()) { return $return; } - public function getMimeType($path) { - if ($this->isReadable($path)) { - return \OC_Helper::getMimeType($this->datadir . $path); - } else { - return false; - } - } - private function delTree($dir) { $dirRelative = $dir; $dir = $this->datadir . $dir; diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index ba5ac4191c5..6c37d445867 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -210,14 +210,6 @@ class MappedLocal extends \OC\Files\Storage\Common{ return $return; } - public function getMimeType($path) { - if($this->isReadable($path)) { - return \OC_Helper::getMimeType($this->buildPath($path)); - }else{ - return false; - } - } - private function delTree($dir, $isLogicPath=true) { $dirRelative=$dir; if ($isLogicPath) { diff --git a/version.php b/version.php index 9b04bd244fb..2e3b8f1f904 100644 --- a/version.php +++ b/version.php @@ -1,10 +1,10 @@ <?php // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel when updating major/minor version number. -$OC_Version=array(6, 00, 0, 7); +$OC_Version=array(6, 00, 0, 8); // The human readable string -$OC_VersionString='6.0 beta 4'; +$OC_VersionString='6.0 beta 5'; // The ownCloud edition $OC_Edition=''; |