[Pkg-owncloud-commits] [php-sabredav] 25/75: Use a better algorithm to compute the ETag.
David Prévot
taffit at moszumanska.debian.org
Thu Feb 26 18:51:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit a97076acf0b26c6fc614e8e0b4b08d5148d545c6
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Thu Jan 8 09:06:15 2015 +0100
Use a better algorithm to compute the ETag.
We use the same algorithm than Apache: inode + filemtime + size.
---
lib/DAV/FS/File.php | 6 +++++-
lib/DAV/FSExt/Directory.php | 6 +++++-
lib/DAV/FSExt/File.php | 8 ++++++--
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/DAV/FS/File.php b/lib/DAV/FS/File.php
index 9cf4464..454e8ad 100644
--- a/lib/DAV/FS/File.php
+++ b/lib/DAV/FS/File.php
@@ -70,7 +70,11 @@ class File extends Node implements DAV\IFile {
*/
function getETag() {
- return '"' . sha1(filemtime($this->path)). '"';
+ return '"' . sha1(
+ fileinode($this->path) .
+ filesize($this->path) .
+ filemtime($this->path)
+ ). '"';
}
diff --git a/lib/DAV/FSExt/Directory.php b/lib/DAV/FSExt/Directory.php
index 20d91cc..8d98a73 100644
--- a/lib/DAV/FSExt/Directory.php
+++ b/lib/DAV/FSExt/Directory.php
@@ -44,7 +44,11 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota, DAV\IMoveTa
$newPath = $this->path . '/' . $name;
file_put_contents($newPath,$data);
- return '"' . md5_file($newPath) . '"';
+ return '"' . sha1(
+ fileinode($newPath) .
+ filesize($newPath) .
+ filemtime($newPath)
+ ). '"';
}
diff --git a/lib/DAV/FSExt/File.php b/lib/DAV/FSExt/File.php
index 0ecd4be..a5cb735 100644
--- a/lib/DAV/FSExt/File.php
+++ b/lib/DAV/FSExt/File.php
@@ -15,7 +15,7 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport {
/**
* Updates the data
*
- * data is a readable stream resource.
+ * Data is a readable stream resource.
*
* @param resource|string $data
* @return string
@@ -112,7 +112,11 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport {
*/
function getETag() {
- return '"' . sha1(filemtime($this->path)). '"';
+ return '"' . sha1(
+ fileinode($this->path) .
+ filesize($this->path) .
+ filemtime($this->path)
+ ). '"';
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list