From 252877865104c4d455249ade5ae7de737d69a2f3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 29 Feb 2012 23:42:40 +0100 Subject: [PATCH] add touch() to all storage backands, and make parameter optional Conflicts: lib/filestorage.php lib/filestorage/common.php lib/filestorage/commontest.php lib/filestorage/local.php lib/filesystemview.php --- apps/files_sharing/sharedstorage.php | 10 ++++++++-- lib/filestorage.php | 1 + lib/filestorage/local.php | 11 ++++++++--- lib/filesystem.php | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index b0eaeecf723..bbb245a82ff 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -569,7 +569,13 @@ class OC_Filestorage_Shared extends OC_Filestorage { return $storage->getLocalFile($this->getInternalPath($source)); } } - + public function touch($path, $mtime=null){ + $source = $this->getSource($path); + if ($source) { + $storage = OC_Filesystem::getStorage($source); + return $storage->touch($this->getInternalPath($source),$time); + } + } } -?> \ No newline at end of file +?> diff --git a/lib/filestorage.php b/lib/filestorage.php index 34fa6457fd2..d6197b88b03 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -53,5 +53,6 @@ class OC_Filestorage{ public function hash($type,$path,$raw){} public function free_space($path){} public function search($query){} + public function touch($path, $mtime=null){} public function getLocalFile($path){}// get a path to a local version of the file, whether the original file is local or remote } diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 71eccb5d1e0..ccf57638f8f 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -70,15 +70,20 @@ class OC_Filestorage_Local extends OC_Filestorage{ public function fileatime($path){ return fileatime($this->datadir.$path); } - public function touch($path, $mtime){ + public function touch($path, $mtime=null){ // 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. - if( touch( $this->datadir.$path, $mtime ) ) { + if(!is_null($mtime)){ + $result=touch( $this->datadir.$path, $mtime ); + }else{ + $result=touch( $this->datadir.$path); + } + if( $result ) { clearstatcache( true, $this->datadir.$path ); } - return touch($this->datadir.$path, $mtime); + return $result; } public function file_get_contents($path){ return file_get_contents($this->datadir.$path); diff --git a/lib/filesystem.php b/lib/filesystem.php index 986dfea64f6..4dfdbc719dc 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -369,7 +369,7 @@ class OC_Filesystem{ static public function fileatime($path){ return self::basicOperation('fileatime',$path); } - static public function touch($path, $mtime){ + static public function touch($path, $mtime=null){ return self::$defaultInstance->touch($path, $mtime); } static public function file_get_contents($path){