public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
$this->storageConfig = $storageConfig;
- parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
+ parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId, ConfigAdapter::class);
}
public function getMountType() {
* @param \OC\Files\Storage\StorageFactory $loader
*/
public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
- parent::__construct($storage, $mountpoint, $options, $loader);
+ parent::__construct($storage, $mountpoint, $options, $loader, null, null, MountProvider::class);
$this->manager = $manager;
}
$newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints, $folderExistCache);
$absMountPoint = '/' . $this->user . '/files' . $newMountPoint;
- parent::__construct($storage, $absMountPoint, $arguments, $loader);
+ parent::__construct($storage, $absMountPoint, $arguments, $loader, null, null, MountProvider::class);
}
/**
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+namespace OC\Core\Migrations;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+/**
+ * Auto-generated migration step: Please modify to your needs!
+ */
+class Version240000Date20220202150027 extends SimpleMigrationStep {
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $table = $schema->getTable('mounts');
+ if (!$table->hasColumn('mount_provider_class')) {
+ $table->addColumn('mount_provider_class', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 128,
+ ]);
+ return $schema;
+ }
+ return null;
+ }
+}
'OC\\Core\\Migrations\\Version23000Date20210930122352' => $baseDir . '/core/Migrations/Version23000Date20210930122352.php',
'OC\\Core\\Migrations\\Version23000Date20211203110726' => $baseDir . '/core/Migrations/Version23000Date20211203110726.php',
'OC\\Core\\Migrations\\Version23000Date20211213203940' => $baseDir . '/core/Migrations/Version23000Date20211213203940.php',
+ 'OC\\Core\\Migrations\\Version240000Date20220202150027' => $baseDir . '/core/Migrations/Version240000Date20220202150027.php',
'OC\\Core\\Migrations\\Version24000Date20211210141942' => $baseDir . '/core/Migrations/Version24000Date20211210141942.php',
'OC\\Core\\Migrations\\Version24000Date20211213081506' => $baseDir . '/core/Migrations/Version24000Date20211213081506.php',
'OC\\Core\\Migrations\\Version24000Date20211213081604' => $baseDir . '/core/Migrations/Version24000Date20211213081604.php',
'OC\\Core\\Migrations\\Version23000Date20210930122352' => __DIR__ . '/../../..' . '/core/Migrations/Version23000Date20210930122352.php',
'OC\\Core\\Migrations\\Version23000Date20211203110726' => __DIR__ . '/../../..' . '/core/Migrations/Version23000Date20211203110726.php',
'OC\\Core\\Migrations\\Version23000Date20211213203940' => __DIR__ . '/../../..' . '/core/Migrations/Version23000Date20211213203940.php',
+ 'OC\\Core\\Migrations\\Version240000Date20220202150027' => __DIR__ . '/../../..' . '/core/Migrations/Version240000Date20220202150027.php',
'OC\\Core\\Migrations\\Version24000Date20211210141942' => __DIR__ . '/../../..' . '/core/Migrations/Version24000Date20211210141942.php',
'OC\\Core\\Migrations\\Version24000Date20211213081506' => __DIR__ . '/../../..' . '/core/Migrations/Version24000Date20211213081506.php',
'OC\\Core\\Migrations\\Version24000Date20211213081604' => __DIR__ . '/../../..' . '/core/Migrations/Version24000Date20211213081604.php',
/** @var string */
private $internalPath;
- public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId, $rootInternalPath, $internalPath) {
- parent::__construct($user, $storageId, $rootId, $mountPoint, $mountId, $rootInternalPath);
+ public function __construct(
+ IUser $user,
+ int $storageId,
+ int $rootId,
+ string $mountPoint,
+ ?int $mountId,
+ string $mountProvider,
+ string $rootInternalPath,
+ string $internalPath
+ ) {
+ parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, $rootInternalPath);
$this->internalPath = $internalPath;
}
- public function getInternalPath() {
+ public function getInternalPath(): string {
if ($this->getRootInternalPath()) {
return substr($this->internalPath, strlen($this->getRootInternalPath()) + 1);
} else {
}
}
- public function getPath() {
+ public function getPath(): string {
return $this->getMountPoint() . $this->getInternalPath();
}
}
*/
protected $rootInternalPath;
+ /** @var string */
+ protected $mountProvider;
+
/**
* CachedMountInfo constructor.
*
* @param int|null $mountId
* @param string $rootInternalPath
*/
- public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null, $rootInternalPath = '') {
+ public function __construct(
+ IUser $user,
+ int $storageId,
+ int $rootId,
+ string $mountPoint,
+ string $mountProvider,
+ int $mountId = null,
+ string $rootInternalPath = ''
+ ) {
$this->user = $user;
$this->storageId = $storageId;
$this->rootId = $rootId;
$this->mountPoint = $mountPoint;
$this->mountId = $mountId;
$this->rootInternalPath = $rootInternalPath;
+ if (strlen($mountProvider) > 128) {
+ throw new \Exception("Mount provider $mountProvider name exceeds the limit of 128 characters");
+ }
+ $this->mountProvider = $mountProvider;
}
/**
public function getRootInternalPath() {
return $this->rootInternalPath;
}
+
+ public function getMountProvider(): string {
+ return $this->mountProvider;
+ }
}
public function getRootInternalPath() {
return $this->mount->getInternalPath($this->mount->getMountPoint());
}
+
+ public function getMountProvider(): string {
+ return $this->mount->getMountProvider();
+ }
}
if (
$newMount->getMountPoint() !== $cachedMount->getMountPoint() ||
$newMount->getStorageId() !== $cachedMount->getStorageId() ||
- $newMount->getMountId() !== $cachedMount->getMountId()
+ $newMount->getMountId() !== $cachedMount->getMountId() ||
+ $newMount->getMountProvider() !== $cachedMount->getMountProvider()
) {
$changed[] = $newMount;
}
'root_id' => $mount->getRootId(),
'user_id' => $mount->getUser()->getUID(),
'mount_point' => $mount->getMountPoint(),
- 'mount_id' => $mount->getMountId()
+ 'mount_id' => $mount->getMountId(),
+ 'mount_provider_class' => $mount->getMountProvider(),
], ['root_id', 'user_id']);
} else {
// in some cases this is legitimate, like orphaned shares
->set('storage_id', $builder->createNamedParameter($mount->getStorageId()))
->set('mount_point', $builder->createNamedParameter($mount->getMountPoint()))
->set('mount_id', $builder->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT))
+ ->set('mount_provider_class', $builder->createNamedParameter($mount->getMountProvider()))
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID())))
->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT)));
if (!is_null($mount_id)) {
$mount_id = (int)$mount_id;
}
- return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $mount_id, isset($row['path']) ? $row['path'] : '');
+ return new CachedMountInfo(
+ $user,
+ (int)$row['storage_id'],
+ (int)$row['root_id'],
+ $row['mount_point'],
+ $row['mount_provider_class'] ?? '',
+ $mount_id,
+ isset($row['path']) ? $row['path'] : '',
+ );
}
/**
public function getMountsForUser(IUser $user) {
if (!isset($this->mountsForUsers[$user->getUID()])) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class')
->from('mounts', 'm')
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID())));
*/
public function getMountsForStorageId($numericStorageId, $user = null) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class')
->from('mounts', 'm')
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT)));
*/
public function getMountsForRootId($rootFileId) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class')
->from('mounts', 'm')
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT)));
/**
* @param $fileId
- * @return array
+ * @return array{int, string, int}
* @throws \OCP\Files\NotFoundException
*/
- private function getCacheInfoFromFileId($fileId) {
+ private function getCacheInfoFromFileId($fileId): array {
if (!isset($this->cacheInfoCache[$fileId])) {
$builder = $this->connection->getQueryBuilder();
$query = $builder->select('storage', 'path', 'mimetype')
if (is_array($row)) {
$this->cacheInfoCache[$fileId] = [
(int)$row['storage'],
- $row['path'],
+ (string)$row['path'],
(int)$row['mimetype']
];
} else {
return [];
}
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class')
->from('mounts', 'm')
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($storageId, IQueryBuilder::PARAM_INT)));
if ($fileId === (int)$row['root_id']) {
return true;
}
- $internalMountPath = isset($row['path']) ? $row['path'] : '';
+ $internalMountPath = $row['path'] ?? '';
return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/';
});
$mount->getRootId(),
$mount->getMountPoint(),
$mount->getMountId(),
+ $mount->getMountProvider(),
$mount->getRootInternalPath(),
$internalPath
);
}
return [
- new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir, $loader]),
- new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads', $loader])
+ new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class),
+ new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class)
];
} else {
return [];
*/
public function getHomeMountForUser(IUser $user, IStorageFactory $loader) {
$arguments = ['user' => $user];
- return new MountPoint('\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader);
+ return new MountPoint('\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader, null, null, self::class);
}
}
use OC\Files\Storage\Storage;
use OC\Files\Storage\StorageFactory;
use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Storage\IStorageFactory;
use OCP\ILogger;
class MountPoint implements IMountPoint {
/** @var int|null */
protected $mountId;
+ /** @var string */
+ protected $mountProvider;
+
/**
* @param string|\OC\Files\Storage\Storage $storage
* @param string $mountpoint
* @param \OCP\Files\Storage\IStorageFactory $loader
* @param array $mountOptions mount specific options
* @param int|null $mountId
+ * @param string|null $mountProvider
* @throws \Exception
*/
- public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
+ public function __construct(
+ $storage,
+ string $mountpoint,
+ array $arguments = null,
+ IStorageFactory $loader = null,
+ array $mountOptions = null,
+ int $mountId = null,
+ string $mountProvider = null
+ ) {
if (is_null($arguments)) {
$arguments = [];
}
$this->class = $storage;
$this->arguments = $arguments;
}
+ if ($mountProvider) {
+ if (strlen($mountProvider) > 128) {
+ throw new \Exception("Mount provider $mountProvider name exceeds the limit of 128 characters");
+ }
+ }
+ $this->mountProvider = $mountProvider ?? '';
}
/**
public function getMountType() {
return '';
}
+
+ public function getMountProvider(): string {
+ return $this->mountProvider;
+ }
}
return null;
}
- return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader);
+ return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader, null, null, self::class);
}
/**
AppdataPreviewObjectStoreStorage::class,
'/appdata_' . $instanceId . '/preview/' . $parent . '/' . $child,
$this->getMultiBucketObjectStore($i),
- $loader
+ $loader,
+ null,
+ null,
+ self::class
);
$i++;
}
$fakeRootStorageJail,
'/appdata_' . $instanceId . '/preview/old-multibucket',
null,
- $loader
+ $loader,
+ null,
+ null,
+ self::class
);
return $mountPoints;
private $folderClosure;
/** @var LazyFolder | null */
- private $folder = null;
+ protected $folder = null;
/**
* LazyFolder constructor.
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace OC\Files\Node;
use OC\Cache\CappedMemoryCache;
* @param IUserManager $userManager
*/
public function __construct($manager,
- $view,
- $user,
+ $view,
+ $user,
IUserMountCache $userMountCache,
ILogger $logger,
IUserManager $userManager) {
/**
* @param string $path
- * @throws \OCP\Files\NotFoundException
- * @throws \OCP\Files\NotPermittedException
* @return Node
+ * @throws \OCP\Files\NotPermittedException
+ * @throws \OCP\Files\NotFoundException
*/
public function get($path) {
$path = $this->normalizePath($path);
/**
* @param string $targetPath
- * @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
+ * @throws \OCP\Files\NotPermittedException
*/
public function rename($targetPath) {
throw new NotPermittedException();
/**
* @param string $targetPath
- * @throws \OCP\Files\NotPermittedException
* @return \OC\Files\Node\Node
+ * @throws \OCP\Files\NotPermittedException
*/
public function copy($targetPath) {
throw new NotPermittedException();
* @since 11.0.0
*/
public function getRootInternalPath();
+
+ /**
+ * Get the class of the mount provider that this mount originates from
+ *
+ * @return string
+ * @since 24.0.0
+ */
+ public function getMountProvider(): string;
}
* @since 12.0.0
*/
public function getMountType();
+
+ /**
+ * Get the class of the mount provider that this mount originates from
+ *
+ * @return string
+ * @since 24.0.0
+ */
+ public function getMountProvider(): string;
}
1,
0,
'/bar/',
+ 'test',
1,
''
)]);
1,
0,
'/bar/',
+ 'test',
1,
''
)]);
1,
0,
'/bar/',
+ 'test',
1,
''
)]);
1,
0,
'/bar/',
+ 'test',
1,
''
),
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
// when updating major/minor version number.
-$OC_Version = [24, 0, 0, 4];
+$OC_Version = [24, 0, 0, 5];
// The human readable string
$OC_VersionString = '24.0.0 dev';