Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
databases: ['sqlite', 'mysql', 'pgsql']
server-versions: ['stable31']
richdocuments-versions: ['stable31']
groupfolders-versions: ['stable31']
primary-storage: ['local', 'minio']

name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}-${{ matrix.primary-storage}}
Expand All @@ -36,11 +37,11 @@ jobs:
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
image: ghcr.io/nextcloud/continuous-integration-minio:latest
image: ghcr.io/nextcloud/continuous-integration-minio:latest # zizmor: ignore[unpinned-images]
ports:
- "9000:9000"
postgres:
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest # zizmor: ignore[unpinned-images]
ports:
- 4445:5432/tcp
env:
Expand All @@ -49,7 +50,7 @@ jobs:
POSTGRES_DB: nextcloud
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
mysql:
image: ghcr.io/nextcloud/continuous-integration-mariadb-10.6:latest
image: ghcr.io/nextcloud/continuous-integration-mariadb-10.6:latest # zizmor: ignore[unpinned-images]
ports:
- 4444:3306/tcp
env:
Expand Down Expand Up @@ -83,6 +84,14 @@ jobs:
repository: nextcloud/richdocuments
ref: ${{ matrix.richdocuments-versions }}

- name: Checkout app (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
path: apps/groupfolders
repository: nextcloud/groupfolders
ref: ${{ matrix.groupfolders-versions }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
Expand All @@ -108,6 +117,10 @@ jobs:
working-directory: apps/richdocuments
run: composer i --no-dev

- name: Set up dependencies (groupfolders)
working-directory: apps/groupfolders
run: composer i --no-dev

- name: Set up Nextcloud for S3 primary storage
if: matrix.primary-storage == 'minio'
run: |
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/phpunit-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
mariadb-versions: ['10.6', '11.4']
richdocuments-versions: ['stable31']
groupfolders-versions: ['stable31']

name: MariaDB ${{ matrix.mariadb-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}

Expand Down Expand Up @@ -113,6 +114,14 @@ jobs:
repository: nextcloud/richdocuments
ref: ${{ matrix.richdocuments-versions }}

- name: Checkout app (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
path: apps/groupfolders
repository: nextcloud/groupfolders
ref: ${{ matrix.groupfolders-versions }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
Expand Down Expand Up @@ -149,6 +158,10 @@ jobs:
working-directory: apps/richdocuments
run: composer i --no-dev

- name: Set up dependencies (groupfolders)
working-directory: apps/groupfolders
run: composer i --no-dev

- name: Set up Nextcloud
env:
DB_PORT: 4444
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
id: versions
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
with:
matrix: '{"mysql-versions": ["8.4"], "richdocuments-versions": ["stable31"]}'
matrix: '{"mysql-versions": ["8.4"], "richdocuments-versions": ["stable31"], "groupfolders-versions": ["stable31"]}'

changes:
runs-on: ubuntu-latest-low
Expand Down Expand Up @@ -110,6 +110,14 @@ jobs:
repository: nextcloud/richdocuments
ref: ${{ matrix.richdocuments-versions }}

- name: Checkout app (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
path: apps/groupfolders
repository: nextcloud/groupfolders
ref: ${{ matrix.groupfolders-versions }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
Expand Down Expand Up @@ -146,6 +154,10 @@ jobs:
working-directory: apps/richdocuments
run: composer i --no-dev

- name: Set up dependencies (groupfolders)
working-directory: apps/groupfolders
run: composer i --no-dev

- name: Set up Nextcloud
env:
DB_PORT: 4444
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/phpunit-oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
richdocuments-versions: ['stable31']
groupfolders-versions: ['stable31']
oci-versions: ['18', '21', '23']

name: OCI ${{ matrix.oci-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
Expand Down Expand Up @@ -123,6 +124,14 @@ jobs:
repository: nextcloud/richdocuments
ref: ${{ matrix.richdocuments-versions }}

- name: Checkout app (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
path: apps/groupfolders
repository: nextcloud/groupfolders
ref: ${{ matrix.groupfolders-versions }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
Expand Down Expand Up @@ -154,6 +163,10 @@ jobs:
working-directory: apps/richdocuments
run: composer i --no-dev

- name: Set up dependencies (groupfolders)
working-directory: apps/groupfolders
run: composer i --no-dev

- name: Set up Nextcloud
env:
DB_PORT: 1521
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
richdocuments-versions: ['stable31']
groupfolders-versions: ['stable31']

name: PostgreSQL PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}

Expand Down Expand Up @@ -114,6 +115,14 @@ jobs:
repository: nextcloud/richdocuments
ref: ${{ matrix.richdocuments-versions }}

- name: Checkout app (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
path: apps/groupfolders
repository: nextcloud/groupfolders
ref: ${{ matrix.groupfolders-versions }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
Expand Down Expand Up @@ -145,6 +154,10 @@ jobs:
working-directory: apps/richdocuments
run: composer i --no-dev

- name: Set up dependencies (groupfolders)
working-directory: apps/groupfolders
run: composer i --no-dev

- name: Set up Nextcloud
env:
DB_PORT: 4444
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
richdocuments-versions: ['stable31']
groupfolders-versions: ['stable31']

name: SQLite PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}

Expand Down Expand Up @@ -103,6 +104,14 @@ jobs:
repository: nextcloud/richdocuments
ref: ${{ matrix.richdocuments-versions }}

- name: Checkout app (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
path: apps/groupfolders
repository: nextcloud/groupfolders
ref: ${{ matrix.groupfolders-versions }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
Expand Down Expand Up @@ -134,6 +143,10 @@ jobs:
working-directory: apps/richdocuments
run: composer i --no-dev

- name: Set up dependencies (groupfolders)
working-directory: apps/groupfolders
run: composer i --no-dev

- name: Set up Nextcloud
env:
DB_PORT: 4444
Expand Down
36 changes: 32 additions & 4 deletions lib/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OC\Files\FileInfo;
use OC\Files\Node\Folder;
use OC\Files\View;
use OCA\GroupFolders\Mount\GroupMountPoint;
use OCA\WorkflowEngine\Entity\File;
use OCP\EventDispatcher\Event;
use OCP\Files\Cache\ICacheEntry;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function checkFileAccess(string $path, IMountPoint $mountPoint, bool $isD

$this->nestingLevel++;

$filePath = $this->translatePath($storage, $path);
$filePath = $this->translatePath($mountPoint, $storage, $path);
$ruleMatcher = $this->manager->getRuleMatcher();
$ruleMatcher->setFileInfo($storage, $filePath, $isDir);
$node = $this->getNode($path, $mountPoint, $cacheEntry);
Expand Down Expand Up @@ -119,8 +120,31 @@ protected function isBlockablePath(IMountPoint $mountPoint, string $path): bool
/**
* For thumbnails and versions we want to check the tags of the original file
*/
protected function translatePath(IStorage $storage, string $path): string {
if (substr_count($path, '/') < 1) {
protected function translatePath(IMountPoint $mountPoint, IStorage $storage, string $path): string {
if ($mountPoint instanceof GroupMountPoint) {
/**
* Case | Mount point path | Path ($path)
* --------+---------------------------------------+--------------------------------
* Files | /user/files/$folderName/ | Subfolder/File.txt
* Trash | /user/files_trashbin/groupfolder/$id/ | Subfolder/File.txt.v{timestamp}
* Version | /user/files_versions/groupfolder/$id/ | Subfolder/File.txt.d{timestamp}
*/
$mountPath = $mountPoint->getMountPoint();
if (substr_count($mountPath, '/') >= 3) {
[,, $folder] = explode('/', $mountPath);
if ($folder === 'files_versions' && preg_match('/.+\.v\d{10}$/', basename($path))) {
// Remove trailing ".v{timestamp}"
return substr($path, 0, -12);
}
if ($folder === 'files_trashbin' && preg_match('/.+\.d\d{10}$/', basename($path))) {
// Remove trailing ".d{timestamp}"
return substr($path, 0, -12);
}
}
return $path;
}

if (substr_count($path, '/') === 0) {
return $path;
}

Expand All @@ -138,7 +162,7 @@ protected function translatePath(IStorage $storage, string $path): string {
// 'versions', 'path/to/file.txt'
$segments = explode('/', $innerPath, 2);
if (isset($segments[1])) {
$innerPath = $segments[1];
[$folder, $innerPath] = $segments;
}

if (preg_match('/.+\.d\d{10}$/', basename($innerPath))) {
Expand Down Expand Up @@ -176,6 +200,10 @@ protected function isCreatingSkeletonFiles(): bool {
isset($step['function']) && $step['function'] === 'tryLogin') {
return true;
}
if (isset($step['class']) && $step['class'] === \OCA\GroupFolders\Trash\TrashBackend::class
&& isset($step['function']) && $step['function'] === 'setupTrashFolder') {
return true;
}
}

return false;
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<file name="tests/stubs/oc_files_cache_wrapper_cachewrapper.php" />
<file name="tests/stubs/oc_files_storage_wrapper_wrapper.php" />
<file name="tests/stubs/oc_files_storage_wrapper_jail.php" />
<file name="tests/stubs/oca_groupfolders.php" />
</stubs>
</psalm>
Loading