本文整理汇总了PHP中OC\Files\Storage\Storage类的典型用法代码示例。如果您正苦于以下问题:PHP Storage类的具体用法?PHP Storage怎么用?PHP Storage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Storage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
}
}
}
示例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;
}
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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');
}
示例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();
}
示例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');
}
示例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();
}
示例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();
}
示例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)));
}
}
示例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');
}
}
示例15: 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']);
}
}
}