瀏覽代碼

add hasUpdated to oc_filestorage

tags/v4.5.0beta1
Robin Appelman 12 年之前
父節點
當前提交
449760f665
共有 5 個檔案被更改,包括 44 行新增0 行删除
  1. 9
    0
      apps/files_sharing/sharedstorage.php
  2. 9
    0
      lib/filestorage.php
  3. 9
    0
      lib/filestorage/common.php
  4. 9
    0
      lib/filestorage/local.php
  5. 8
    0
      tests/lib/filestorage.php

+ 9
- 0
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()) {

+ 9
- 0
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);
}

+ 9
- 0
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;
}
}

+ 9
- 0
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;
}
}

+ 8
- 0
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(){

Loading…
取消
儲存