Merge pull request #1835 from nextcloud/downstream-24948

Move OC\Files\Storage\Shared to the right namespace
This commit is contained in:
Morris Jobke 2016-10-20 23:48:15 +02:00 committed by GitHub
commit 2799b0a821
23 changed files with 39 additions and 34 deletions

View File

@ -250,8 +250,8 @@ abstract class Node implements \Sabre\DAV\INode {
$path = $this->info->getInternalPath(); $path = $this->info->getInternalPath();
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) { if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
/** @var \OC\Files\Storage\Shared $storage */ /** @var \OCA\Files_Sharing\SharedStorage $storage */
$permissions = (int)$storage->getShare()->getPermissions(); $permissions = (int)$storage->getShare()->getPermissions();
} else { } else {
$permissions = $storage->getPermissions($path); $permissions = $storage->getPermissions($path);

View File

@ -216,7 +216,7 @@ class DirectoryTest extends \Test\TestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('instanceOfStorage') ->method('instanceOfStorage')
->will($this->returnValueMap([ ->will($this->returnValueMap([
'\OC\Files\Storage\Shared' => false, '\OCA\Files_Sharing\SharedStorage' => false,
'\OC\Files\Storage\Wrapper\Quota' => false, '\OC\Files\Storage\Wrapper\Quota' => false,
])); ]));
@ -247,7 +247,7 @@ class DirectoryTest extends \Test\TestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('instanceOfStorage') ->method('instanceOfStorage')
->will($this->returnValueMap([ ->will($this->returnValueMap([
['\OC\Files\Storage\Shared', false], ['\OCA\Files_Sharing\SharedStorage', false],
['\OC\Files\Storage\Wrapper\Quota', true], ['\OC\Files\Storage\Wrapper\Quota', true],
])); ]));

View File

@ -113,7 +113,7 @@ abstract class TestCase extends \Test\TestCase {
* reset init status for the share storage * reset init status for the share storage
*/ */
protected static function resetStorage() { protected static function resetStorage() {
$storage = new \ReflectionClass('\OC\Files\Storage\Shared'); $storage = new \ReflectionClass('\OCA\Files_Sharing\SharedStorage');
$isInitialized = $storage->getProperty('initialized'); $isInitialized = $storage->getProperty('initialized');
$isInitialized->setAccessible(true); $isInitialized->setAccessible(true);
$isInitialized->setValue($storage, false); $isInitialized->setValue($storage, false);

View File

@ -28,8 +28,6 @@
$l = \OC::$server->getL10N('files_sharing'); $l = \OC::$server->getL10N('files_sharing');
\OC::$CLASSPATH['OC\Files\Storage\Shared'] = 'files_sharing/lib/sharedstorage.php';
\OCA\Files_Sharing\Helper::registerHooks(); \OCA\Files_Sharing\Helper::registerHooks();
\OCP\Share::registerBackend('file', 'OCA\Files_Sharing\ShareBackend\File'); \OCP\Share::registerBackend('file', 'OCA\Files_Sharing\ShareBackend\File');

View File

@ -38,7 +38,7 @@ use OCP\Files\Storage\IStorage;
*/ */
class Cache extends CacheJail { class Cache extends CacheJail {
/** /**
* @var \OC\Files\Storage\Shared * @var \OCA\Files_Sharing\SharedStorage
*/ */
private $storage; private $storage;
@ -58,7 +58,7 @@ class Cache extends CacheJail {
private $sourceCache; private $sourceCache;
/** /**
* @param \OC\Files\Storage\Shared $storage * @param \OCA\Files_Sharing\SharedStorage $storage
* @param IStorage $sourceStorage * @param IStorage $sourceStorage
* @param ICacheEntry $sourceRootInfo * @param ICacheEntry $sourceRootInfo
*/ */

View File

@ -81,7 +81,7 @@ class MountProvider implements IMountProvider {
foreach ($superShares as $share) { foreach ($superShares as $share) {
try { try {
$mounts[] = new SharedMount( $mounts[] = new SharedMount(
'\OC\Files\Storage\Shared', '\OCA\Files_Sharing\SharedStorage',
$mounts, $mounts,
[ [
'user' => $user->getUID(), 'user' => $user->getUID(),

View File

@ -55,7 +55,7 @@ class Scanner extends \OC\Files\Cache\Scanner {
if ($this->sourceScanner) { if ($this->sourceScanner) {
return $this->sourceScanner; return $this->sourceScanner;
} }
if ($this->storage->instanceOfStorage('\OC\Files\Storage\Shared')) { if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
/** @var \OC\Files\Storage\Storage $storage */ /** @var \OC\Files\Storage\Storage $storage */
list($storage) = $this->storage->resolvePath(''); list($storage) = $this->storage->resolvePath('');
$this->sourceScanner = $storage->getScanner(); $this->sourceScanner = $storage->getScanner();

View File

@ -37,7 +37,7 @@ use OC\Files\View;
*/ */
class SharedMount extends MountPoint implements MoveableMount { class SharedMount extends MountPoint implements MoveableMount {
/** /**
* @var \OC\Files\Storage\Shared $storage * @var \OCA\Files_Sharing\SharedStorage $storage
*/ */
protected $storage = null; protected $storage = null;
@ -212,7 +212,7 @@ class SharedMount extends MountPoint implements MoveableMount {
*/ */
public function removeMount() { public function removeMount() {
$mountManager = \OC\Files\Filesystem::getMountManager(); $mountManager = \OC\Files\Filesystem::getMountManager();
/** @var $storage \OC\Files\Storage\Shared */ /** @var $storage \OCA\Files_Sharing\SharedStorage */
$storage = $this->getStorage(); $storage = $this->getStorage();
$result = $storage->unshareStorage(); $result = $storage->unshareStorage();
$mountManager->removeMount($this->mountPoint); $mountManager->removeMount($this->mountPoint);

View File

@ -27,7 +27,7 @@ use OC\Files\Cache\Propagator;
class SharedPropagator extends Propagator { class SharedPropagator extends Propagator {
/** /**
* @var \OC\Files\Storage\Shared * @var \OCA\Files_Sharing\SharedStorage
*/ */
protected $storage; protected $storage;

View File

@ -29,11 +29,10 @@
* *
*/ */
namespace OC\Files\Storage; namespace OCA\Files_Sharing;
use OC\Files\Filesystem; use OC\Files\Filesystem;
use OC\Files\Cache\FailedCache; use OC\Files\Cache\FailedCache;
use OCA\Files_Sharing\ISharedStorage;
use OCP\Constants; use OCP\Constants;
use OCP\Files\Cache\ICacheEntry; use OCP\Files\Cache\ICacheEntry;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
@ -43,7 +42,8 @@ use OCP\Lock\ILockingProvider;
/** /**
* Convert target path to source path and pass the function call to the correct storage provider * Convert target path to source path and pass the function call to the correct storage provider
*/ */
class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage { class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
/** @var \OCP\Share\IShare */ /** @var \OCP\Share\IShare */
private $superShare; private $superShare;

View File

@ -488,7 +488,7 @@ class CacheTest extends TestCase {
$this->assertTrue(\OC\Files\Filesystem::file_exists('/test.txt')); $this->assertTrue(\OC\Files\Filesystem::file_exists('/test.txt'));
list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test.txt'); list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test.txt');
/** /**
* @var \OC\Files\Storage\Shared $sharedStorage * @var \OCA\Files_Sharing\SharedStorage $sharedStorage
*/ */
$sharedCache = $sharedStorage->getCache(); $sharedCache = $sharedStorage->getCache();
@ -518,7 +518,7 @@ class CacheTest extends TestCase {
$this->assertTrue(\OC\Files\Filesystem::file_exists('/foo')); $this->assertTrue(\OC\Files\Filesystem::file_exists('/foo'));
list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo'); list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
/** /**
* @var \OC\Files\Storage\Shared $sharedStorage * @var \OCA\Files_Sharing\SharedStorage $sharedStorage
*/ */
$sharedCache = $sharedStorage->getCache(); $sharedCache = $sharedStorage->getCache();

View File

@ -523,7 +523,7 @@ class SharedStorageTest extends TestCase {
$mount = $view2->getMount('/foo'); $mount = $view2->getMount('/foo');
$this->assertInstanceOf('\OCA\Files_Sharing\SharedMount', $mount); $this->assertInstanceOf('\OCA\Files_Sharing\SharedMount', $mount);
/** @var \OC\Files\Storage\Shared $storage */ /** @var \OCA\Files_Sharing\SharedStorage $storage */
$storage = $mount->getStorage(); $storage = $mount->getStorage();
$this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $storage->getOwner('')); $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $storage->getOwner(''));

View File

@ -184,7 +184,7 @@ abstract class TestCase extends \Test\TestCase {
* reset init status for the share storage * reset init status for the share storage
*/ */
protected static function resetStorage() { protected static function resetStorage() {
$storage = new \ReflectionClass('\OC\Files\Storage\Shared'); $storage = new \ReflectionClass('\OCA\Files_Sharing\SharedStorage');
$isInitialized = $storage->getProperty('initialized'); $isInitialized = $storage->getProperty('initialized');
$isInitialized->setAccessible(true); $isInitialized->setAccessible(true);
$isInitialized->setValue($storage, false); $isInitialized->setValue($storage, false);

View File

@ -881,7 +881,7 @@ class VersioningTest extends \Test\TestCase {
\OC::$server->getUserManager()->registerBackend($backend); \OC::$server->getUserManager()->registerBackend($backend);
} }
$storage = new \ReflectionClass('\OC\Files\Storage\Shared'); $storage = new \ReflectionClass('\OCA\Files_Sharing\SharedStorage');
$isInitialized = $storage->getProperty('initialized'); $isInitialized = $storage->getProperty('initialized');
$isInitialized->setAccessible(true); $isInitialized->setAccessible(true);
$isInitialized->setValue($storage, false); $isInitialized->setValue($storage, false);

View File

@ -211,7 +211,7 @@ class DecryptAll {
$content = $this->rootView->getDirectoryContent($root); $content = $this->rootView->getDirectoryContent($root);
foreach ($content as $file) { foreach ($content as $file) {
// only decrypt files owned by the user // only decrypt files owned by the user
if($file->getStorage()->instanceOfStorage('OC\Files\Storage\Shared')) { if($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) {
continue; continue;
} }
$path = $root . '/' . $file['name']; $path = $root . '/' . $file['name'];

View File

@ -81,7 +81,7 @@ class EncryptionWrapper {
'mount' => $mount 'mount' => $mount
]; ];
if (!$storage->instanceOfStorage('OC\Files\Storage\Shared') if (!$storage->instanceOfStorage('OCA\Files_Sharing\SharedStorage')
&& !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage') && !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')
&& !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud')) { && !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud')) {

View File

@ -466,6 +466,10 @@ abstract class Common implements Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function instanceOfStorage($class) { public function instanceOfStorage($class) {
if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') {
// FIXME Temporary fix to keep existing checks working
$class = '\OCA\Files_Sharing\SharedStorage';
}
return is_a($this, $class); return is_a($this, $class);
} }

View File

@ -483,6 +483,10 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function instanceOfStorage($class) { public function instanceOfStorage($class) {
if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') {
// FIXME Temporary fix to keep existing checks working
$class = '\OCA\Files_Sharing\SharedStorage';
}
return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class); return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class);
} }

View File

@ -1357,7 +1357,7 @@ class View {
$subStorage = $mount->getStorage(); $subStorage = $mount->getStorage();
if ($subStorage) { if ($subStorage) {
// exclude shared storage ? // exclude shared storage ?
if ($extOnly && $subStorage instanceof \OC\Files\Storage\Shared) { if ($extOnly && $subStorage instanceof \OCA\Files_Sharing\SharedStorage) {
continue; continue;
} }
$subCache = $subStorage->getCache(''); $subCache = $subStorage->getCache('');

View File

@ -557,7 +557,7 @@ class OC_Helper {
$quota = \OCP\Files\FileInfo::SPACE_UNLIMITED; $quota = \OCP\Files\FileInfo::SPACE_UNLIMITED;
$storage = $rootInfo->getStorage(); $storage = $rootInfo->getStorage();
$sourceStorage = $storage; $sourceStorage = $storage;
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) { if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
$includeExtStorage = false; $includeExtStorage = false;
$sourceStorage = $storage->getSourceStorage(); $sourceStorage = $storage->getSourceStorage();
} }

View File

@ -165,15 +165,14 @@ class OC_Util {
// install storage availability wrapper, before most other wrappers // install storage availability wrapper, before most other wrappers
\OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, $storage) { \OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, $storage) {
/** @var \OCP\Files\Storage $storage */ if (!$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) {
if (!$storage->instanceOfStorage('\OC\Files\Storage\Shared') && !$storage->isLocal()) {
return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]); return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]);
} }
return $storage; return $storage;
}); });
\OC\Files\Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { \OC\Files\Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) {
if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OC\Files\Storage\Shared') && !$storage->isLocal()) { if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) {
return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]); return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]);
} }
return $storage; return $storage;

View File

@ -260,7 +260,7 @@ class DecryptAllTest extends TestCase {
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$sharedStorage->expects($this->once())->method('instanceOfStorage') $sharedStorage->expects($this->once())->method('instanceOfStorage')
->with('OC\Files\Storage\Shared')->willReturn(true); ->with('OCA\Files_Sharing\SharedStorage')->willReturn(true);
$this->view->expects($this->at(0))->method('getDirectoryContent') $this->view->expects($this->at(0))->method('getDirectoryContent')
->with('/user1/files')->willReturn( ->with('/user1/files')->willReturn(

View File

@ -91,13 +91,13 @@ class EncryptionWrapperTest extends TestCase {
[true, ['OCA\Files_Trashbin\Storage']], [true, ['OCA\Files_Trashbin\Storage']],
// Do not wrap shared storages // Do not wrap shared storages
[false, ['OC\Files\Storage\Shared']], [false, ['OCA\Files_Sharing\SharedStorage']],
[false, ['OCA\Files_Sharing\External\Storage']], [false, ['OCA\Files_Sharing\External\Storage']],
[false, ['OC\Files\Storage\OwnCloud']], [false, ['OC\Files\Storage\OwnCloud']],
[false, ['OC\Files\Storage\Shared', 'OCA\Files_Sharing\External\Storage']], [false, ['OCA\Files_Sharing\SharedStorage', 'OCA\Files_Sharing\External\Storage']],
[false, ['OC\Files\Storage\Shared', 'OC\Files\Storage\OwnCloud']], [false, ['OCA\Files_Sharing\SharedStorage', 'OC\Files\Storage\OwnCloud']],
[false, ['OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']], [false, ['OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']],
[false, ['OC\Files\Storage\Shared', 'OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']], [false, ['OCA\Files_Sharing\SharedStorage', 'OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']],
]; ];
} }