[Pkg-owncloud-commits] [owncloud] 117/165: move permission related code into getMetaData()
David Prévot
taffit at moszumanska.debian.org
Thu Apr 23 04:06:45 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 32995ace1c1ea453e08b1afd6f6d43cf68f2e3b1
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date: Mon Apr 20 16:50:12 2015 +0200
move permission related code into getMetaData()
---
lib/private/files/cache/scanner.php | 10 ++--------
lib/private/files/storage/common.php | 8 ++++++++
lib/private/files/storage/wrapper/encryption.php | 17 ++++++++++-------
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 713dcda..d253afb 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -103,16 +103,10 @@ class Scanner extends BasicEmitter {
* @return array an array of metadata of the file
*/
public function getData($path) {
- $permissions = $this->storage->getPermissions($path);
- if (!$permissions & \OCP\PERMISSION_READ) {
- //cant read, nothing we can do
+ $data = $this->storage->getMetaData($path);
+ if (is_null($data)) {
\OCP\Util::writeLog('OC\Files\Cache\Scanner', "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG);
- return null;
}
-
- $data = $this->storage->getMetaData($path);
- $data['permissions'] = $permissions;
-
return $data;
}
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index 7667821..06c61fe 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -585,6 +585,12 @@ abstract class Common implements Storage {
* @inheritdoc
*/
public function getMetaData($path) {
+ $permissions = $this->getPermissions($path);
+ if (!$permissions & \OCP\Constants::PERMISSION_READ) {
+ //cant read, nothing we can do
+ return null;
+ }
+
$data = [];
$data['mimetype'] = $this->getMimeType($path);
$data['mtime'] = $this->filemtime($path);
@@ -595,6 +601,8 @@ abstract class Common implements Storage {
}
$data['etag'] = $this->getETag($path);
$data['storage_mtime'] = $data['mtime'];
+ $data['permissions'] = $this->getPermissions($path);
+
return $data;
}
}
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 125e5f0..e5c9628 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -23,6 +23,8 @@
namespace OC\Files\Storage\Wrapper;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
+use OC\Encryption\File;
+use OC\Files\Filesystem;
use OC\Files\Storage\LocalTempFileTrait;
use OCP\Files\Mount\IMountPoint;
@@ -48,7 +50,7 @@ class Encryption extends Wrapper {
/** @var array */
private $unencryptedSize;
- /** @var \OC\Encryption\File */
+ /** @var File */
private $fileHelper;
/** @var IMountPoint */
@@ -59,7 +61,7 @@ class Encryption extends Wrapper {
* @param \OC\Encryption\Manager $encryptionManager
* @param \OC\Encryption\Util $util
* @param \OC\Log $logger
- * @param \OC\Encryption\File $fileHelper
+ * @param File $fileHelper
* @param string $uid user who perform the read/write operation (null for public access)
*/
public function __construct(
@@ -67,7 +69,7 @@ class Encryption extends Wrapper {
\OC\Encryption\Manager $encryptionManager = null,
\OC\Encryption\Util $util = null,
\OC\Log $logger = null,
- \OC\Encryption\File $fileHelper = null,
+ File $fileHelper = null,
$uid = null
) {
@@ -116,13 +118,14 @@ class Encryption extends Wrapper {
*/
public function getMetaData($path) {
$data = $this->storage->getMetaData($path);
+ if (is_null($data)) {
+ return null;
+ }
$fullPath = $this->getFullPath($path);
if (isset($this->unencryptedSize[$fullPath])) {
- $size = $this->unencryptedSize[$fullPath];
-
$data['encrypted'] = true;
- $data['size'] = $size;
+ $data['size'] = $this->unencryptedSize[$fullPath];
} else {
$info = $this->getCache()->get($path);
if (isset($info['fileid']) && $info['encrypted']) {
@@ -383,7 +386,7 @@ class Encryption extends Wrapper {
* @return string full path including mount point
*/
protected function getFullPath($path) {
- return \OC\Files\Filesystem::normalizePath($this->mountPoint . '/' . $path);
+ return Filesystem::normalizePath($this->mountPoint . '/' . $path);
}
/**
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list