[Pkg-owncloud-commits] [owncloud] 47/75: Cherrypick: Added the ability to change a files mtime via webdavs propset.
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:08:39 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v3.0.1
in repository owncloud.
commit 71e71b75eeb7ac0719df149ecb2b34d3312b2490
Author: Klaas Freitag <freitag at owncloud.com>
Date: Fri Feb 10 11:30:38 2012 +0100
Cherrypick: Added the ability to change a files mtime via webdavs propset.
---
lib/connector/sabre/node.php | 30 +++++++++++++++++++++++-------
lib/filestorage/local.php | 10 ++++++++++
lib/filesystem.php | 3 +++
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index ace572a..b8b675c 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -92,6 +92,19 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
+ /**
+ * sets the last modification time of the file (mtime) to the value given
+ * in the second parameter or to now if the second param is empty.
+ * Even if the modification time is set to a custom value the access time is set to now.
+ */
+ public function setLastModifiedTime($mtime) {
+ OC_Filesystem::setFileMtime($this->path, $mtime);
+ }
+
+ public function endsWith( $str, $sub ) {
+ return ( substr( $str, strlen( $str ) - strlen( $sub ) ) === $sub );
+ }
+
/**
* Updates properties on this node,
*
@@ -110,13 +123,16 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
}
else {
- if(!array_key_exists( $propertyName, $existing )){
- $query = OC_DB::prepare( 'INSERT INTO *PREFIX*properties (userid,propertypath,propertyname,propertyvalue) VALUES(?,?,?,?)' );
- $query->execute( array( OC_User::getUser(), $this->path, $propertyName,$propertyValue ));
- }
- else{
- $query = OC_DB::prepare( 'UPDATE *PREFIX*properties SET propertyvalue = ? WHERE userid = ? AND propertypath = ? AND propertyname = ?' );
- $query->execute( array( $propertyValue,OC_User::getUser(), $this->path, $propertyName ));
+ if( $this->endsWith( $propertyName, "modificationTime")) {
+ $this->setLastModifiedTime($propertyValue);
+ } else {
+ if(!array_key_exists( $propertyName, $existing )){
+ $query = OC_DB::prepare( 'INSERT INTO *PREFIX*properties (userid,propertypath,propertyname,propertyvalue) VALUES(?,?,?,?)' );
+ $query->execute( array( OC_User::getUser(), $this->path, $propertyName,$propertyValue ));
+ } else {
+ $query = OC_DB::prepare( 'UPDATE *PREFIX*properties SET propertyvalue = ? WHERE userid = ? AND propertypath = ? AND propertyname = ?' );
+ $query->execute( array( $propertyValue,OC_User::getUser(), $this->path, $propertyName ));
+ }
}
}
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index e846aa4..3c96ff6 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -67,9 +67,19 @@ class OC_Filestorage_Local extends OC_Filestorage{
public function filemtime($path){
return filemtime($this->datadir.$path);
}
+<<<<<<< HEAD
public function fileatime($path){
return fileatime($this->datadir.$path);
}
+=======
+
+ public function setFileMtime($path, $mtime){
+ // sets the modification time of the file to the given value. If mtime is nil the current time is set.
+ // note that the access time of the file always changes to the current time.
+ return touch($this->datadir.$path, $mtime);
+ }
+
+>>>>>>> 85853f9... - Added the ability to change a files mtime via webdavs propset.
public function file_get_contents($path){
return file_get_contents($this->datadir.$path);
}
diff --git a/lib/filesystem.php b/lib/filesystem.php
index bd953de..e92dc7d 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -369,6 +369,9 @@ class OC_Filesystem{
static public function fileatime($path){
return self::basicOperation('fileatime',$path);
}
+ static public function setFileMtime($path, $mtime){
+ return self::$defaultInstance->setFileMtime($path, $mtime);
+ }
static public function file_get_contents($path){
return self::basicOperation('file_get_contents',$path,array('read'));
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list