mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #58827 from nextcloud/fix/fix-fileinfo-path
fix(files): Fix FileInfo['path'] situation
This commit is contained in:
commit
c98244a79e
4 changed files with 13 additions and 14 deletions
|
|
@ -230,14 +230,14 @@ class CacheTest extends TestCase {
|
|||
[
|
||||
[
|
||||
'name' => 'shareddir',
|
||||
'path' => 'files/shareddir',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/shareddir',
|
||||
'mimetype' => 'httpd/unix-directory',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
],
|
||||
[
|
||||
'name' => 'shared single file.txt',
|
||||
'path' => 'files/shared single file.txt',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/shared single file.txt',
|
||||
'mimetype' => 'text/plain',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
|
|
@ -254,21 +254,21 @@ class CacheTest extends TestCase {
|
|||
[
|
||||
[
|
||||
'name' => 'bar.txt',
|
||||
'path' => 'bar.txt',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/shareddir/bar.txt',
|
||||
'mimetype' => 'text/plain',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
],
|
||||
[
|
||||
'name' => 'emptydir',
|
||||
'path' => 'emptydir',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/shareddir/emptydir',
|
||||
'mimetype' => 'httpd/unix-directory',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
],
|
||||
[
|
||||
'name' => 'subdir',
|
||||
'path' => 'subdir',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/shareddir/subdir',
|
||||
'mimetype' => 'httpd/unix-directory',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
|
|
@ -336,21 +336,21 @@ class CacheTest extends TestCase {
|
|||
[
|
||||
[
|
||||
'name' => 'another too.txt',
|
||||
'path' => 'another too.txt',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER3 . '/files/subdir/another too.txt',
|
||||
'mimetype' => 'text/plain',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
],
|
||||
[
|
||||
'name' => 'another.txt',
|
||||
'path' => 'another.txt',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER3 . '/files/subdir/another.txt',
|
||||
'mimetype' => 'text/plain',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
],
|
||||
[
|
||||
'name' => 'not a text file.xml',
|
||||
'path' => 'not a text file.xml',
|
||||
'path' => '/' . self::TEST_FILES_SHARING_API_USER3 . '/files/subdir/not a text file.xml',
|
||||
'mimetype' => 'application/xml',
|
||||
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
|
||||
'displayname_owner' => 'User One',
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
|
|||
|
||||
public function offsetGet(mixed $offset): mixed {
|
||||
return match ($offset) {
|
||||
'path' => $this->getPath(),
|
||||
'type' => $this->getType(),
|
||||
'etag' => $this->getEtag(),
|
||||
'size' => $this->getSize(),
|
||||
|
|
|
|||
|
|
@ -1642,8 +1642,6 @@ class View {
|
|||
$rootEntry['permissions'] = $permissions & (Constants::PERMISSION_ALL - (Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE));
|
||||
}
|
||||
|
||||
$rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
|
||||
|
||||
// if sharing was disabled for the user we remove the share permissions
|
||||
if ($sharingDisabled) {
|
||||
$rootEntry['permissions'] = $rootEntry['permissions'] & ~Constants::PERMISSION_SHARE;
|
||||
|
|
|
|||
|
|
@ -414,8 +414,8 @@ class ViewTest extends \Test\TestCase {
|
|||
foreach ($results as $result) {
|
||||
$paths[] = $result['path'];
|
||||
}
|
||||
$this->assertContains('/anotherstorage/folder/bar.txt', $paths);
|
||||
$this->assertContains('/bar.txt', $paths);
|
||||
$this->assertContains('/folder/anotherstorage/folder/bar.txt', $paths);
|
||||
$this->assertContains('/folder/bar.txt', $paths);
|
||||
|
||||
$results = $folderView->search('foo');
|
||||
$this->assertCount(2, $results);
|
||||
|
|
@ -423,8 +423,8 @@ class ViewTest extends \Test\TestCase {
|
|||
foreach ($results as $result) {
|
||||
$paths[] = $result['path'];
|
||||
}
|
||||
$this->assertContains('/anotherstorage/foo.txt', $paths);
|
||||
$this->assertContains('/anotherstorage/foo.png', $paths);
|
||||
$this->assertContains('/folder/anotherstorage/foo.txt', $paths);
|
||||
$this->assertContains('/folder/anotherstorage/foo.png', $paths);
|
||||
|
||||
$this->assertCount(6, $rootView->searchByMime('text'));
|
||||
$this->assertCount(3, $folderView->searchByMime('text'));
|
||||
|
|
|
|||
Loading…
Reference in a new issue