aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-06-15 16:43:24 +0200
committerRobin Appelman <icewind@owncloud.com>2012-06-15 16:43:24 +0200
commit449760f665a2416875458cbb3f34387df038b08a (patch)
tree3ad398644dee204c3b7bdc16c95effcc30d094b1
parent6ca87656befb4ae30bd17547f34e6c3263c83c64 (diff)
downloadnextcloud-server-449760f665a2416875458cbb3f34387df038b08a.tar.gz
nextcloud-server-449760f665a2416875458cbb3f34387df038b08a.zip
add hasUpdated to oc_filestorage
-rw-r--r--apps/files_sharing/sharedstorage.php9
-rw-r--r--lib/filestorage.php9
-rw-r--r--lib/filestorage/common.php9
-rw-r--r--lib/filestorage/local.php9
-rw-r--r--tests/lib/filestorage.php8
5 files changed, 44 insertions, 0 deletions
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 3bb6e73035e..1a6942ad160 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -512,6 +512,15 @@ class OC_Filestorage_Shared extends OC_Filestorage {
OC_Filesystem::mount('OC_Filestorage_Shared', array('datadir' => '/'.OCP\USER::getUser().'/files/Shared'), '/'.OCP\USER::getUser().'/files/Shared/');
}
+ /**
+ * check if a file or folder has been updated since $time
+ * @param int $time
+ * @return bool
+ */
+ public function hasUpdated($path,$time){
+ //TODO
+ return $this->filemtime($path)>$time;
+ }
}
if (OCP\USER::isLoggedIn()) {
diff --git a/lib/filestorage.php b/lib/filestorage.php
index 1d7e004af3b..71ef4aed00b 100644
--- a/lib/filestorage.php
+++ b/lib/filestorage.php
@@ -50,4 +50,13 @@ abstract class OC_Filestorage{
abstract public function search($query);
abstract public function touch($path, $mtime=null);
abstract public function getLocalFile($path);// get a path to a local version of the file, whether the original file is local or remote
+ /**
+ * check if a file or folder has been updated since $time
+ * @param int $time
+ * @return bool
+ *
+ * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
+ * returning true for other changes in the folder is optional
+ */
+ abstract public function hasUpdated($path,$time);
}
diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php
index f0bfc064cb5..f2a5775fd19 100644
--- a/lib/filestorage/common.php
+++ b/lib/filestorage/common.php
@@ -156,4 +156,13 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
}
return $files;
}
+
+ /**
+ * check if a file or folder has been updated since $time
+ * @param int $time
+ * @return bool
+ */
+ public function hasUpdated($path,$time){
+ return $this->filemtime($path)>$time;
+ }
}
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index ea9a9070263..44a2ab0f634 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -194,4 +194,13 @@ class OC_Filestorage_Local extends OC_Filestorage{
public function getFolderSize($path){
return 0;//depricated, use OC_FileCach instead
}
+
+ /**
+ * check if a file or folder has been updated since $time
+ * @param int $time
+ * @return bool
+ */
+ public function hasUpdated($path,$time){
+ return $this->filemtime($path)>$time;
+ }
}
diff --git a/tests/lib/filestorage.php b/tests/lib/filestorage.php
index f71b658253a..00f37b9f1a2 100644
--- a/tests/lib/filestorage.php
+++ b/tests/lib/filestorage.php
@@ -149,6 +149,9 @@ abstract class Test_FileStorage extends UnitTestCase {
$this->assertTrue(($ctimeStart-1)<=$cTime);
$this->assertTrue($cTime<=($ctimeEnd+1));
}
+ $this->assertTrue($this->instance->hasUpdated('/lorem.txt',$ctimeStart-1));
+ $this->assertTrue($this->instance->hasUpdated('/',$ctimeStart-1));
+
$this->assertTrue(($ctimeStart-1)<=$mTime);
$this->assertTrue($mTime<=($ctimeEnd+1));
$this->assertEqual(filesize($textFile),$this->instance->filesize('/lorem.txt'));
@@ -168,6 +171,8 @@ abstract class Test_FileStorage extends UnitTestCase {
$this->assertTrue(($mtimeStart-1)<=$mTime);
$this->assertTrue($mTime<=($mtimeEnd+1));
$this->assertEqual($cTime,$originalCTime);
+
+ $this->assertTrue($this->instance->hasUpdated('/lorem.txt',$mtimeStart-1));
if($this->instance->touch('/lorem.txt',100)!==false){
$mTime=$this->instance->filemtime('/lorem.txt');
@@ -184,6 +189,9 @@ abstract class Test_FileStorage extends UnitTestCase {
$mTime=$this->instance->filemtime('/lorem.txt');
$this->assertTrue(($mtimeStart-1)<=$mTime);
$this->assertTrue($mTime<=($mtimeEnd+1));
+
+ $this->instance->unlink('/lorem.txt');
+ $this->assertTrue($this->instance->hasUpdated('/',$mtimeStart-1));
}
public function testSearch(){