fall back to getLocalFile if storage doesn't support fseek

remotes/origin/stable6
Bjoern Schiessle 13 years ago
parent d93b5af265
commit f87319f834
  1. 16
      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

Loading…
Cancel
Save