本文整理汇总了PHP中OC\Files\Storage\Storage类的典型用法代码示例。如果您正苦于以下问题:PHP Storage类的具体用法?PHP Storage怎么用?PHP Storage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Storage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
* @throws \RuntimeException
*/
public function __construct($storage)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
$this->storageId = self::adjustStorageId($this->storageId);
$sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
$result = \OC_DB::executeAudited($sql, array($this->storageId));
if ($row = $result->fetchRow()) {
$this->numericId = $row['numeric_id'];
} else {
$connection = \OC_DB::getConnection();
if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId])) {
$this->numericId = \OC_DB::insertid('*PREFIX*storages');
} else {
$result = \OC_DB::executeAudited($sql, array($this->storageId));
if ($row = $result->fetchRow()) {
$this->numericId = $row['numeric_id'];
} else {
throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
}
}
}
}
开发者ID:samj1912,项目名称:repo,代码行数:30,代码来源:storage.php
示例2: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
public function __construct($storage)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:11,代码来源:permissions.php
示例3: setUp
protected function setUp()
{
parent::setUp();
$this->remoteUser = $this->getUniqueID('remoteuser');
$this->storage = $this->getMockBuilder('\\OCA\\Files_Sharing\\External\\Storage')->disableOriginalConstructor()->getMock();
$this->storage->expects($this->any())->method('getId')->will($this->returnValue('dummystorage::'));
$this->cache = new \OCA\Files_Sharing\External\Cache($this->storage, 'http://example.com/owncloud', $this->remoteUser);
$this->cache->put('test.txt', array('mimetype' => 'text/plain', 'size' => 5, 'mtime' => 123));
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:9,代码来源:cache.php
示例4: testGetPermissions
/**
* Test that the permissions of shared directory are returned correctly
*/
function testGetPermissions()
{
$sharedDirPerms = $this->sharedStorage->getPermissions('shareddir');
$this->assertEquals(31, $sharedDirPerms);
$sharedDirPerms = $this->sharedStorage->getPermissions('shareddir/textfile.txt');
$this->assertEquals(31, $sharedDirPerms);
$sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted');
$this->assertEquals(7, $sharedDirRestrictedPerms);
$sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted/textfile.txt');
$this->assertEquals(7, $sharedDirRestrictedPerms);
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:14,代码来源:permissions.php
示例5: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
public function __construct($storage)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
if (strlen($this->storageId) > 64) {
$this->storageId = md5($this->storageId);
}
$this->storageCache = new Storage($storage);
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:15,代码来源:cache.php
示例6: getStorageMock
/**
* Returns a storage mock that returns the given value as
* free space
*
* @param int $freeSpace free space value
* @return \OC\Files\Storage\Storage
*/
private function getStorageMock($freeSpace = 12) {
$this->storageMock = $this->getMock(
'\OC\Files\Storage\Temporary',
array('free_space'),
array('')
);
$this->storageMock->expects($this->once())
->method('free_space')
->will($this->returnValue(12));
return $this->storageMock;
}
开发者ID:ninjasilicon,项目名称:core,代码行数:20,代码来源:helperstorage.php
示例7: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
public function __construct($storage)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
if (strlen($this->storageId) > 64) {
$this->storageId = md5($this->storageId);
}
$this->storageCache = new Storage($storage);
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
}
开发者ID:rajeshpillai,项目名称:core,代码行数:16,代码来源:cache.php
示例8: setUp
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');
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:28,代码来源:updater.php
示例9: tearDown
protected function tearDown()
{
\OC_User::setUserId($this->user);
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
$cache->clear();
}
if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
}
$this->logout();
parent::tearDown();
}
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:14,代码来源:view.php
示例10: setUp
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');
}
开发者ID:ninjasilicon,项目名称:core,代码行数:30,代码来源:updaterlegacy.php
示例11: tearDown
protected function tearDown()
{
\OC_User::setUserId($this->user);
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
$cache->clear();
}
if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
}
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
parent::tearDown();
}
开发者ID:riso,项目名称:owncloud-core,代码行数:15,代码来源:view.php
示例12: commitBatch
/**
* Commit the active propagation batch
*/
public function commitBatch()
{
if (!$this->inBatch) {
throw new \BadMethodCallException('Not in batch');
}
$this->inBatch = false;
$this->connection->beginTransaction();
$query = $this->connection->getQueryBuilder();
$storageId = (int) $this->storage->getStorageCache()->getNumericId();
$query->update('filecache')->set('mtime', $query->createFunction('GREATEST(`mtime`, ' . $query->createParameter('time') . ')'))->set('etag', $query->expr()->literal(uniqid()))->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT)))->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash')));
$sizeQuery = $this->connection->getQueryBuilder();
$sizeQuery->update('filecache')->set('size', $sizeQuery->createFunction('`size` + ' . $sizeQuery->createParameter('size')))->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT)))->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash')))->andWhere($sizeQuery->expr()->gt('size', $sizeQuery->expr()->literal(-1, IQueryBuilder::PARAM_INT)));
foreach ($this->batch as $item) {
$query->setParameter('time', $item['time'], IQueryBuilder::PARAM_INT);
$query->setParameter('hash', $item['hash']);
$query->execute();
if ($item['size']) {
$sizeQuery->setParameter('size', $item['size'], IQueryBuilder::PARAM_INT);
$sizeQuery->setParameter('hash', $item['hash']);
$sizeQuery->execute();
}
}
$this->batch = [];
$this->connection->commit();
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:28,代码来源:Propagator.php
示例13: correctParentStorageMtime
/**
* update the storage_mtime of the direct parent in the cache to the mtime from the storage
*
* @param string $internalPath
*/
private function correctParentStorageMtime($internalPath)
{
$parentId = $this->cache->getParentId($internalPath);
$parent = dirname($internalPath);
if ($parentId != -1) {
$this->cache->update($parentId, array('storage_mtime' => $this->storage->filemtime($parent)));
}
}
开发者ID:farukuzun,项目名称:core-1,代码行数:13,代码来源:updater.php
示例14: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
public function __construct($storage)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
$this->storageId = self::adjustStorageId($this->storageId);
$sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
$result = \OC_DB::executeAudited($sql, array($this->storageId));
if ($row = $result->fetchRow()) {
$this->numericId = $row['numeric_id'];
} else {
$sql = 'INSERT INTO `*PREFIX*storages` (`id`) VALUES(?)';
\OC_DB::executeAudited($sql, array($this->storageId));
$this->numericId = \OC_DB::insertid('*PREFIX*storages');
}
}
开发者ID:Combustible,项目名称:core,代码行数:21,代码来源:storage.php
示例15: testMoveFolderCrossStorage
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']);
}
}
开发者ID:ninjasilicon,项目名称:core,代码行数:54,代码来源:updater.php
示例16: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
public function __construct($storage)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
if (strlen($this->storageId) > 64) {
$this->storageId = md5($this->storageId);
}
$query = \OC_DB::prepare('SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?');
$result = $query->execute(array($this->storageId));
if ($row = $result->fetchRow()) {
$this->numericId = $row['numeric_id'];
} else {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*storages`(`id`) VALUES(?)');
$query->execute(array($this->storageId));
$this->numericId = \OC_DB::insertid('*PREFIX*storages');
}
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:23,代码来源:cache.php
示例17: propagateChange
/**
* @param string $internalPath
* @param int $time
* @param int $sizeDifference number of bytes the file has grown
*/
public function propagateChange($internalPath, $time, $sizeDifference = 0)
{
$storageId = (int) $this->storage->getStorageCache()->getNumericId();
$parents = $this->getParents($internalPath);
$parentHashes = array_map('md5', $parents);
$etag = uniqid();
// since we give all folders the same etag we don't ask the storage for the etag
$builder = $this->connection->getQueryBuilder();
$hashParams = array_map(function ($hash) use($builder) {
return $builder->expr()->literal($hash);
}, $parentHashes);
$builder->update('filecache')->set('mtime', $builder->createFunction('GREATEST(`mtime`, ' . $builder->createNamedParameter($time) . ')'))->set('etag', $builder->createNamedParameter($etag, IQueryBuilder::PARAM_STR))->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))->andWhere($builder->expr()->in('path_hash', $hashParams));
$builder->execute();
if ($sizeDifference !== 0) {
// we need to do size separably so we can ignore entries with uncalculated size
$builder = $this->connection->getQueryBuilder();
$builder->update('filecache')->set('size', $builder->createFunction('`size` + ' . $builder->createNamedParameter($sizeDifference)))->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))->andWhere($builder->expr()->in('path_hash', $hashParams))->andWhere($builder->expr()->gt('size', $builder->expr()->literal(-1, IQueryBuilder::PARAM_INT)));
}
$builder->execute();
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:25,代码来源:Propagator.php
示例18: __construct
/**
* @param \OC\Files\Storage\Storage|string $storage
* @param bool $isAvailable
* @throws \RuntimeException
*/
public function __construct($storage, $isAvailable = true)
{
if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
} else {
$this->storageId = $storage;
}
$this->storageId = self::adjustStorageId($this->storageId);
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = $row['numeric_id'];
} else {
$connection = \OC_DB::getConnection();
if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $isAvailable])) {
$this->numericId = \OC_DB::insertid('*PREFIX*storages');
} else {
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = $row['numeric_id'];
} else {
throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
}
}
}
}
开发者ID:rosarion,项目名称:core,代码行数:28,代码来源:storage.php
示例19: testSearchByTagTree
/**
* 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'));
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:19,代码来源:cache.php
示例20: cleanFolder
/**
* remove deleted files in $path from the cache
*
* @param string $path
*/
public function cleanFolder($path)
{
$cachedContent = $this->cache->getFolderContents($path);
foreach ($cachedContent as $entry) {
if (!$this->storage->file_exists($entry['path'])) {
$this->cache->remove($entry['path']);
}
}
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:14,代码来源:watcher.php
注:本文中的OC\Files\Storage\Storage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论