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.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 577b656077f..70398183f8b 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -473,7 +473,9 @@ class Util {
$data = '';
$handle = $this->view->fopen($path, 'r');
if (is_resource($handle)) {
- if (fseek($handle, -24, SEEK_END) === 0) {
+ // suppress fseek warining, we handle the case that fseek doesn't
+ // work in the else branch
+ if (@fseek($handle, -24, SEEK_END) === 0) {
$data = fgets($handle);
} else {
// if fseek failed on the storage we create a local copy from the file
@@ -537,7 +539,20 @@ class Util {
$lastChunckPos = ($lastChunkNr * 8192);
// seek to end
- fseek($stream, $lastChunckPos);
+ if (@fseek($stream, $lastChunckPos) === -1) {
+ // storage doesn't support fseek, we need a local copy
+ fclose($stream);
+ $localFile = $this->view->getLocalFile($path);
+ Helper::addTmpFileToMapper($localFile, $path);
+ $stream = fopen('crypt://' . $localFile, "r");
+ if (fseek($stream, $lastChunckPos) === -1) {
+ // if fseek also fails on the local storage, than
+ // there is nothing we can do
+ fclose($stream);
+ \OCP\Util::writeLog('Encryption library', 'couldn\'t determine size of "' . $path, \OCP\Util::ERROR);
+ return $result;
+ }
+ }
// get the content of the last chunk
$lastChunkContent = fread($stream, $lastChunkSize);