mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fall back to getLocalFile if storage doesn't support fseek
This commit is contained in:
parent
69b89454a4
commit
c955381d56
1 changed files with 14 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue