Sfoglia il codice sorgente

Improve etag handling

Check if values exist before using them

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Roeland Jago Douma 4 anni fa
parent
commit
0568b01267
1 ha cambiato i file con 20 aggiunte e 6 eliminazioni
  1. 20 6
      lib/private/Files/Storage/Local.php

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

@@ -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);
 		}