コード例 #1
0
ファイル: updaterlegacy.php プロジェクト: ninjasilicon/core
	protected function setUp() {
		parent::setUp();

		$this->storage = new \OC\Files\Storage\Temporary(array());
		$textData = "dummy file data\n";
		$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
		$this->storage->mkdir('folder');
		$this->storage->file_put_contents('foo.txt', $textData);
		$this->storage->file_put_contents('foo.png', $imgData);
		$this->storage->file_put_contents('folder/bar.txt', $textData);
		$this->storage->file_put_contents('folder/bar2.txt', $textData);

		$this->scanner = $this->storage->getScanner();
		$this->scanner->scan('');
		$this->cache = $this->storage->getCache();

		if (!self::$user) {
			self::$user = $this->getUniqueID();
		}

		\OC_User::createUser(self::$user, 'password');
		$this->loginAsUser(self::$user);

		Filesystem::init(self::$user, '/' . self::$user . '/files');

		Filesystem::clearMounts();
		Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');

		\OC_Hook::clear('OC_Filesystem');
	}
コード例 #2
0
ファイル: updater.php プロジェクト: olucao/owncloud-core
 public function setUp()
 {
     // remember files_encryption state
     $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
     // we want to tests with the encryption app disabled
     \OC_App::disable('files_encryption');
     $this->storage = new \OC\Files\Storage\Temporary(array());
     $textData = "dummy file data\n";
     $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
     $this->storage->mkdir('folder');
     $this->storage->file_put_contents('foo.txt', $textData);
     $this->storage->file_put_contents('foo.png', $imgData);
     $this->storage->file_put_contents('folder/bar.txt', $textData);
     $this->storage->file_put_contents('folder/bar2.txt', $textData);
     $this->scanner = $this->storage->getScanner();
     $this->scanner->scan('');
     $this->cache = $this->storage->getCache();
     \OC\Files\Filesystem::tearDown();
     if (!self::$user) {
         self::$user = uniqid();
     }
     \OC_User::createUser(self::$user, 'password');
     \OC_User::setUserId(self::$user);
     \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
     Filesystem::clearMounts();
     Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
     \OC_Hook::clear('OC_Filesystem');
 }
コード例 #3
0
ファイル: noopscanner.php プロジェクト: evanjt/core
 function testBackgroundScan()
 {
     $this->fillTestFolders();
     $this->storage->mkdir('folder2');
     $this->storage->file_put_contents('folder2/bar.txt', 'foobar');
     $this->assertEquals([], $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW), 'Asserting that no error occurred while scan(SCAN_SHALLOW)');
     $this->scanner->backgroundScan();
     $this->assertTrue(true, 'Asserting that no error occurred while backgroundScan()');
 }
コード例 #4
0
ファイル: updater.php プロジェクト: ninjasilicon/core
	public function testMoveFolderCrossStorage() {
		$storage2 = new Temporary(array());
		$cache2 = $storage2->getCache();
		Filesystem::mount($storage2, array(), '/bar');
		$this->storage->mkdir('foo');
		$this->storage->mkdir('foo/bar');
		$this->storage->file_put_contents('foo/foo.txt', 'qwerty');
		$this->storage->file_put_contents('foo/bar.txt', 'foo');
		$this->storage->file_put_contents('foo/bar/bar.txt', 'qwertyuiop');

		$this->storage->getScanner()->scan('');

		$this->assertTrue($this->cache->inCache('foo'));
		$this->assertTrue($this->cache->inCache('foo/foo.txt'));
		$this->assertTrue($this->cache->inCache('foo/bar.txt'));
		$this->assertTrue($this->cache->inCache('foo/bar'));
		$this->assertTrue($this->cache->inCache('foo/bar/bar.txt'));
		$cached = [];
		$cached[] = $this->cache->get('foo');
		$cached[] = $this->cache->get('foo/foo.txt');
		$cached[] = $this->cache->get('foo/bar.txt');
		$cached[] = $this->cache->get('foo/bar');
		$cached[] = $this->cache->get('foo/bar/bar.txt');

		// add extension to trigger the possible mimetype change
		$this->view->rename('/foo', '/bar/foo.b');

		$this->assertFalse($this->cache->inCache('foo'));
		$this->assertFalse($this->cache->inCache('foo/foo.txt'));
		$this->assertFalse($this->cache->inCache('foo/bar.txt'));
		$this->assertFalse($this->cache->inCache('foo/bar'));
		$this->assertFalse($this->cache->inCache('foo/bar/bar.txt'));
		$this->assertTrue($cache2->inCache('foo.b'));
		$this->assertTrue($cache2->inCache('foo.b/foo.txt'));
		$this->assertTrue($cache2->inCache('foo.b/bar.txt'));
		$this->assertTrue($cache2->inCache('foo.b/bar'));
		$this->assertTrue($cache2->inCache('foo.b/bar/bar.txt'));

		$cachedTarget = [];
		$cachedTarget[] = $cache2->get('foo.b');
		$cachedTarget[] = $cache2->get('foo.b/foo.txt');
		$cachedTarget[] = $cache2->get('foo.b/bar.txt');
		$cachedTarget[] = $cache2->get('foo.b/bar');
		$cachedTarget[] = $cache2->get('foo.b/bar/bar.txt');

		foreach ($cached as $i => $old) {
			$new = $cachedTarget[$i];
			$this->assertEquals($old['mtime'], $new['mtime']);
			$this->assertEquals($old['size'], $new['size']);
			$this->assertEquals($old['etag'], $new['etag']);
			$this->assertEquals($old['fileid'], $new['fileid']);
			$this->assertEquals($old['mimetype'], $new['mimetype']);
		}
	}
コード例 #5
0
ファイル: cache.php プロジェクト: enoch85/owncloud-testserver
 /**
  * Test searching by tag for multiple sections of the tree
  */
 function testSearchByTagTree()
 {
     $userId = \OC::$server->getUserSession()->getUser()->getUId();
     $this->sharedStorage->mkdir('subdir/emptydir');
     $this->sharedStorage->mkdir('subdir/emptydir2');
     $this->ownerStorage->getScanner()->scan('');
     $allIds = array($this->sharedCache->get('')['fileid'], $this->sharedCache->get('bar.txt')['fileid'], $this->sharedCache->get('subdir/another too.txt')['fileid'], $this->sharedCache->get('subdir/not a text file.xml')['fileid'], $this->sharedCache->get('subdir/another.txt')['fileid'], $this->sharedCache->get('subdir/emptydir')['fileid'], $this->sharedCache->get('subdir/emptydir2')['fileid']);
     $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId);
     foreach ($allIds as $id) {
         $tagManager->tagAs($id, 'tag1');
     }
     $results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
     $check = array(array('name' => 'shareddir', 'path' => ''), array('name' => 'bar.txt', 'path' => 'bar.txt'), array('name' => 'another.txt', 'path' => 'subdir/another.txt'), array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), array('name' => 'emptydir', 'path' => 'subdir/emptydir'), array('name' => 'emptydir2', 'path' => 'subdir/emptydir2'), array('name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'));
     $this->verifyFiles($check, $results);
     $tagManager->delete(array('tag1'));
 }
コード例 #6
0
ファイル: scanner.php プロジェクト: 0x17de/core
 function testBackgroundScan()
 {
     $this->fillTestFolders();
     $this->storage->mkdir('folder2');
     $this->storage->file_put_contents('folder2/bar.txt', 'foobar');
     $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
     $this->assertFalse($this->cache->inCache('folder/bar.txt'));
     $this->assertFalse($this->cache->inCache('folder/2bar.txt'));
     $cachedData = $this->cache->get('');
     $this->assertEquals(-1, $cachedData['size']);
     $this->scanner->backgroundScan();
     $this->assertTrue($this->cache->inCache('folder/bar.txt'));
     $this->assertTrue($this->cache->inCache('folder/bar.txt'));
     $cachedData = $this->cache->get('');
     $this->assertnotEquals(-1, $cachedData['size']);
     $this->assertFalse($this->cache->getIncomplete());
 }
コード例 #7
0
 function testBackgroundScanOnlyRecurseIncomplete()
 {
     $this->fillTestFolders();
     $this->storage->mkdir('folder2');
     $this->storage->file_put_contents('folder2/bar.txt', 'foobar');
     $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
     $this->assertFalse($this->cache->inCache('folder/bar.txt'));
     $this->assertFalse($this->cache->inCache('folder/2bar.txt'));
     $this->assertFalse($this->cache->inCache('folder2/bar.txt'));
     $this->cache->put('folder2', ['size' => 1]);
     // mark as complete
     $cachedData = $this->cache->get('');
     $this->assertEquals(-1, $cachedData['size']);
     $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE_INCOMPLETE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
     $this->assertTrue($this->cache->inCache('folder/bar.txt'));
     $this->assertTrue($this->cache->inCache('folder/bar.txt'));
     $this->assertFalse($this->cache->inCache('folder2/bar.txt'));
     $cachedData = $this->cache->get('');
     $this->assertNotEquals(-1, $cachedData['size']);
     $this->assertFalse($this->cache->getIncomplete());
 }
コード例 #8
0
ファイル: Wrapper.php プロジェクト: GitHubUser4234/core
 /**
  * see http://php.net/manual/en/function.mkdir.php
  *
  * @param string $path
  * @return bool
  */
 public function mkdir($path)
 {
     return $this->storage->mkdir($path);
 }