summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib/util.php')
-rw-r--r--apps/files_encryption/lib/util.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index a2aa305b64c..121b1c4f573 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -587,11 +587,18 @@ class Util {
) {
// get the size from filesystem
- $fullPath = $this->view->getLocalFile($path);
$size = $this->view->filesize($path);
+ // fast path, else the calculation for $lastChunkNr is bogus
+ if ($size === 0) {
+ \OC_FileProxy::$enabled = $proxyStatus;
+ return 0;
+ }
+
// calculate last chunk nr
- $lastChunkNr = floor($size / 8192);
+ // next highest is end of chunks, one subtracted is last one
+ // we have to read the last chunk, we can't just calculate it (because of padding etc)
+ $lastChunkNr = ceil($size/ 8192) - 1;
$lastChunkSize = $size - ($lastChunkNr * 8192);
// open stream