Browse Source

Improve etag handling

Check if values exist before using them

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
tags/v18.0.0beta1
Roeland Jago Douma 4 years ago
parent
commit
0568b01267
No account linked to committer's email address
1 changed files with 20 additions and 6 deletions
  1. 20
    6
      lib/private/Files/Storage/Local.php

+ 20
- 6
lib/private/Files/Storage/Local.php View File

@@ -424,12 +424,26 @@ class Local extends \OC\Files\Storage\Common {
public function getETag($path) {
if ($this->is_file($path)) {
$stat = $this->stat($path);
return md5(
$stat['mtime'] .
$stat['ino'] .
$stat['dev'] .
$stat['size']
);

if ($stat === false) {
return md5('');
}

$toHash = '';
if (isset($stat['mtime'])) {
$toHash .= $stat['mtime'];
}
if (isset($stat['ino'])) {
$toHash .= $stat['ino'];
}
if (isset($stat['dev'])) {
$toHash .= $stat['dev'];
}
if (isset($stat['size'])) {
$toHash .= $stat['size'];
}

return md5($toHash);
} else {
return parent::getETag($path);
}

Loading…
Cancel
Save