Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IUserMountCache->getMountsForFileId #21858

Merged
merged 3 commits into from
Jan 28, 2016
Merged

Conversation

icewind1991
Copy link
Contributor

Fixes #21846

Usage example:

$mountCache = \OC::$server->getMountProviderCollection()->getMountCache()
$mounts = $mountCache->getMountsForFileId($fileId);
$userWithAccessToFile = array_map(function(ICachedMountInfo $mount) {
    return $mount->getUser();
}, $mounts);
$mountCache = \OC::$server->getMountProviderCollection()->getMountCache()
$mounts = $mountCache->getMountsForFileId($fileId);
if (count($mounts) > 0) {
    $node = $mounts[0]->getMountPointNode();
    $owner = $node->getOwner();
}

cc @PVince81 @nickvergessen

@icewind1991 icewind1991 added this to the 9.0-current milestone Jan 22, 2016
@@ -53,6 +55,8 @@ class UserMountCache implements IUserMountCache {
*/
private $logger;

private $cacheInfoCache = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha, why not a cacheCacheCache ?

@PVince81
Copy link
Contributor

So for system-wide mounts, getMountsForFileId() would just return several mounts, one for each user ?
Then from the mount it should be easy to access the matching storage ?

Code looks good 👍

@LukasReschke
Copy link
Member

Seems like this makes PGSQL unhappy?

1:17:36 
11:17:36 1) Test\Files\Config\UserMountCache::testGetMountsForFileIdRootId
11:17:36 Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'INSERT INTO "oc_filecache" ("fileid","storage","path","path_hash","parent","name","mimetype","mimepart","size","storage_mtime","encrypted","unencrypted_size","etag","permissions") SELECT ?,?,?,?,?,?,?,?,?,?,?,?,?,? FROM "oc_filecache" WHERE "fileid" = ? AND "storage" = ? AND "path" = ? AND "path_hash" = ? AND "parent" = ? AND "name" = ? AND "mimetype" = ? AND "mimepart" = ? AND "size" = ? AND "storage_mtime" = ? AND "encrypted" = ? AND "unencrypted_size" = ? AND "etag" = ? AND "permissions" = ? HAVING COUNT(*) = 0' with params [-2, 2, "", "d41d8cd98f00b204e9800998ecf8427e", -1, "", 0, 0, 0, 0, false, 0, "", 31, -2, 2, "", "d41d8cd98f00b204e9800998ecf8427e", -1, "", 0, 0, 0, 0, false, 0, "", 31]:
11:17:36 
11:17:36 SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: ""
11:17:36 
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php:91
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:116
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:996
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/lib/private/db/connection.php:204
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/lib/private/db/adapter.php:93
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/lib/private/db/connection.php:242
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/tests/lib/files/config/usermountcache.php:282
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/tests/lib/files/config/usermountcache.php:288
11:17:36 
11:17:36 Caused by
11:17:36 Doctrine\DBAL\Driver\PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: ""
11:17:36 
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:989
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/lib/private/db/connection.php:204
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/lib/private/db/adapter.php:93
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/lib/private/db/connection.php:242
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/tests/lib/files/config/usermountcache.php:282
11:17:36 /ssd/jenkins/workspace/core-ci-linux@3/database/pgsql/label/SLAVE/tests/lib/files/config/usermountcache.php:288
11:17:36 
[snip]

@nickvergessen
Copy link
Contributor

The problem is autoincrement numbers can not be negative?

$builder = $this->connection->getQueryBuilder();
$query = $builder->select('storage', 'path')
->from('filecache')
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, \PDO::PARAM_INT)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the constant IQueryBuilder::PARAM_INT

@nickvergessen
Copy link
Contributor

  • Rebased to have the IQueryBuilder:: constants
  • Fixed the constant usage
  • Fixed failing oracle and postgres tests

@PVince81
Copy link
Contributor

All tests pass, ready for review ? @nickvergessen @icewind1991

@icewind1991
Copy link
Contributor Author

👍 for @nickvergessen's part

@PVince81
Copy link
Contributor

👍 for the latest changes.

@nickvergessen one last thumbs up for Robin's commits ?

@nickvergessen
Copy link
Contributor

Works and makes it possible to do the stuff I need to do:
👍

DeepDiver1975 added a commit that referenced this pull request Jan 28, 2016
add IUserMountCache->getMountsForFileId
@DeepDiver1975 DeepDiver1975 merged commit b7710ab into master Jan 28, 2016
@DeepDiver1975 DeepDiver1975 deleted the getMountsForFileId branch January 28, 2016 10:20
@settermjd
Copy link
Contributor

settermjd commented Jan 12, 2017

For updating the docs, is /developer_manual/app/filesystem.html the correct location? @DeepDiver1975 @PVince81?

@PVince81
Copy link
Contributor

I don't know. I guess it's fine.

@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement getOwnerByFileId
6 participants