summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-10-14 16:34:14 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-10-22 11:54:00 +0200
commit004b4dbcb63836ba467c0b3deb0b988a0387dffd (patch)
tree92785cc1f4ff79e8d4a20587b2ee9bd86e4ea168 /apps
parent7923f93ee3b63cf1359f03b9d5beecb486b7e8a5 (diff)
downloadnextcloud-server-004b4dbcb63836ba467c0b3deb0b988a0387dffd.tar.gz
nextcloud-server-004b4dbcb63836ba467c0b3deb0b988a0387dffd.zip
try to fix unencrypted file size if it doesn't look plausible
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/lib/proxy.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 958286a29c1..2a77632b0c3 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -319,6 +319,16 @@ class Proxy extends \OC_FileProxy {
$view = new \OC_FilesystemView('/');
+ $userId = \OCP\User::getUser();
+ $util = new Util($view, $userId);
+
+ // if encryption is no longer enabled or if the files aren't migrated yet
+ // we return the default file size
+ if(!\OCP\App::isEnabled('files_encryption') ||
+ $util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) {
+ return $size;
+ }
+
// if path is a folder do nothing
if ($view->is_dir($path)) {
return $size;
@@ -340,6 +350,15 @@ class Proxy extends \OC_FileProxy {
// if file is encrypted return real file size
if (is_array($fileInfo) && $fileInfo['encrypted'] === true) {
+ // try to fix unencrypted file size if it doesn't look plausible
+ if ((int)$fileInfo['size'] > 0 && (int)$fileInfo['encrypted_size'] === 0) {
+ $fixSize = $util->getFileSize($path);
+ $fileInfo['unencrypted_size'] = $fixSize;
+ // put file info if not .part file
+ if (!Keymanager::isPartialFilePath($relativePath)) {
+ $view->putFileInfo($path, $fileInfo);
+ }
+ }
$size = $fileInfo['unencrypted_size'];
} else {
// self healing if file was removed from file cache
@@ -347,8 +366,6 @@ class Proxy extends \OC_FileProxy {
$fileInfo = array();
}
- $userId = \OCP\User::getUser();
- $util = new Util($view, $userId);
$fixSize = $util->getFileSize($path);
if ($fixSize > 0) {
$size = $fixSize;