diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-12-17 16:18:05 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-12-17 16:18:05 +0100 |
commit | c955381d5691be00053e52a0e43df698478d979c (patch) | |
tree | 53b0501d3041c6376b733a2bd7e0e7ea895e9037 | |
parent | 69b89454a4070c0ae3e7e8b6e37f310a2ee28e73 (diff) | |
download | nextcloud-server-c955381d5691be00053e52a0e43df698478d979c.tar.gz nextcloud-server-c955381d5691be00053e52a0e43df698478d979c.zip |
fall back to getLocalFile if storage doesn't support fseek
-rw-r--r-- | apps/files_encryption/lib/util.php | 16 |
1 files changed, 14 insertions, 2 deletions
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 |