diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-10-16 02:25:28 -0700 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-10-16 02:25:28 -0700 |
commit | 9f8d52ee44a425e6afc32782d1cd51e6e7225a9a (patch) | |
tree | 79e0cad257d1f09ea50c733df1ce8296abf33276 | |
parent | 97905775b0ea9d0384a2c65be9c454b61e0cda65 (diff) | |
parent | 6bfd8bdf63329460a472462a60d40d3b345f42e0 (diff) | |
download | nextcloud-server-9f8d52ee44a425e6afc32782d1cd51e6e7225a9a.tar.gz nextcloud-server-9f8d52ee44a425e6afc32782d1cd51e6e7225a9a.zip |
Merge pull request #5329 from owncloud/enc_fix_unencrypted_size
try to fix unencrypted file size if it doesn't look plausible
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 04795b35670..6dc5c9ce1b8 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -317,6 +317,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; @@ -338,6 +348,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['unencrypted_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 @@ -345,8 +364,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; |