From: Bjoern Schiessle Date: Tue, 17 Dec 2013 15:18:05 +0000 (+0100) Subject: fall back to getLocalFile if storage doesn't support fseek X-Git-Tag: v7.0.0alpha2~1003^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c955381d5691be00053e52a0e43df698478d979c;p=nextcloud-server.git fall back to getLocalFile if storage doesn't support fseek --- diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index d4aa4d31649..577b656077f 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -472,8 +472,20 @@ class Util { // we only need 24 byte from the last chunk $data = ''; $handle = $this->view->fopen($path, 'r'); - if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) { - $data = fgets($handle); + if (is_resource($handle)) { + 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 + // and read this one + fclose($handle); + $localFile = $this->view->getLocalFile($path); + $handle = fopen($localFile, 'r'); + if (is_resource($handle) && fseek($handle, -24, SEEK_END) === 0) { + $data = fgets($handle); + } + } + fclose($handle); } // re-enable proxy