[Pkg-owncloud-commits] [owncloud] 02/134: fall back to getLocalFile if storage doesn't support fseek
David Prévot
taffit at moszumanska.debian.org
Fri Apr 18 21:43:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit f87319f834aa3858ac338cc400a310b23ff0e903
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Tue Dec 17 16:18:05 2013 +0100
fall back to getLocalFile if storage doesn't support fseek
---
apps/files_encryption/lib/util.php | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 4a04220..06768b3 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -477,8 +477,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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list