From b24b6f857c4e2264eae9dc82ee63b5468abaf6c4 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 28 Sep 2026 14:17:48 +0200 Subject: [PATCH 01/16] first pass to align with flysystem 3 --- src/Nextcloud.php | 60 ++---- src/NextcloudCalendar.php | 35 ++-- src/NextcloudContacts.php | 42 ++-- src/NextcloudContacts.php~ | 412 +++++++++++++++++++++++++++++++++++++ src/NextcloudProfile.php | 42 ++-- 5 files changed, 485 insertions(+), 106 deletions(-) create mode 100644 src/NextcloudContacts.php~ diff --git a/src/Nextcloud.php b/src/Nextcloud.php index 3795469..6eb32d5 100644 --- a/src/Nextcloud.php +++ b/src/Nextcloud.php @@ -50,7 +50,7 @@ final public function copy($path, $newpath) * * @throws \OCP\Files\NotPermittedException */ - final public function createDir($dirname, Config $config) + final public function createDirectory($dirname, Config $config) { $this->folder->newFolder($dirname); @@ -90,7 +90,7 @@ final public function delete($path) * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotPermittedException */ - final public function deleteDir($dirname) + final public function deleteDirectory($dirname) { $result = false; @@ -146,7 +146,7 @@ final public function getMimeType($path) * * @return array|false */ - final public function getSize($path) + final public function fileSize($path) { return $this->getMetadata($path); } @@ -158,7 +158,7 @@ final public function getSize($path) * * @return array|false */ - final public function getTimestamp($path) + final public function lastModified($path) { return $this->getMetadata($path); } @@ -170,7 +170,7 @@ final public function getTimestamp($path) * * @return array|false */ - final public function getVisibility($path) + final public function visibility($path) { return $this->getMetadata($path); } @@ -182,7 +182,19 @@ final public function getVisibility($path) * * @return array|bool|null */ - final public function has($path) + final public function fileExists($path) + { + return $this->folder->nodeExists($path); + } + + /** + * Check whether a directory exists. + * + * @param string $path + * + * @return array|bool|null + */ + final public function directoryExists($path) { return $this->folder->nodeExists($path); } @@ -285,7 +297,7 @@ final public function readStream($path) * @throws \OCP\Files\NotPermittedException * @throws \OCP\Lock\LockedException */ - final public function rename($path, $newpath) + final public function move($path, $newpath) { try { $this->folder->get($path)->move($newpath); @@ -309,38 +321,6 @@ final public function setVisibility($path, $visibility) return false; } - /** - * Update a file. - * - * @param string $path - * @param string $contents - * @param Config $config Config object - * - * @return array|false false on failure file meta data on success - * - * @throws \OCP\Files\InvalidPathException - */ - final public function update($path, $contents, Config $config) - { - return $this->write($path, $contents, $config); - } - - /** - * Update a file using a stream. - * - * @param string $path - * @param resource $resource - * @param Config $config Config object - * - * @return array|false false on failure file meta data on success - * - * @throws \OCP\Files\NotPermittedException - */ - final public function updateStream($path, $resource, Config $config) - { - return $this->writeStream($path, $resource, $config); - } - /** * Write a new file. * @@ -409,7 +389,7 @@ final public function writeStream($path, $resource, Config $config) // @CHECKME: Do we need to create a directory or will the Node do that for us? if ($folder === false) { - $this->createDir($dirname, $config); + $this->createDirectory($dirname, $config); } $stream = $node->fopen('w+b'); diff --git a/src/NextcloudCalendar.php b/src/NextcloudCalendar.php index 88e7c63..60b360e 100644 --- a/src/NextcloudCalendar.php +++ b/src/NextcloudCalendar.php @@ -89,7 +89,7 @@ final public function copy($path, $newpath) * * @throws Exception */ - final public function createDir($calendarName, Config $config) + final public function createDirectory($calendarName, Config $config) { $calendarId = $this->calDavBackend->createCalendar($this->principalUri, $calendarName, []); if ($calendarId !== null) { @@ -120,7 +120,7 @@ final public function delete($path) * * @return bool */ - final public function deleteDir($calendar) + final public function deleteDirectory($calendar) { $calendarId = $this->getCalendarId($calendar); if (!$calendarId) { @@ -171,7 +171,7 @@ final public function getMetadata($path) * * @return array|false */ - final public function getMimeType($path) + final public function mimeType($path) { return $this->getMetadata($path); } @@ -183,7 +183,7 @@ final public function getMimeType($path) * * @return array|false */ - final public function getSize($path) + final public function fileSize($path) { return $this->getMetadata($path); } @@ -195,7 +195,7 @@ final public function getSize($path) * * @return array|false */ - final public function getTimestamp($path) + final public function lastModified($path) { return $this->getMetadata($path); } @@ -207,7 +207,7 @@ final public function getTimestamp($path) * * @return array|false */ - final public function getVisibility($path) + final public function visibility($path) { return $this->getMetadata($path); } @@ -219,7 +219,7 @@ final public function getVisibility($path) * * @return bool */ - final public function has($path) + final public function fileExists($path) { if ($path === '.acl' && $this->defaultAcl) { return true; @@ -237,6 +237,11 @@ final public function has($path) } } + final public function directoryExists($path) + { + return $this->fileExists($path); + } + /** * List contents of a directory. * @@ -298,7 +303,7 @@ final public function read($path) * * @return bool */ - final public function rename($path, $newpath) + final public function move($path, $newpath) { return false; } @@ -316,20 +321,6 @@ final public function setVisibility($path, $visibility) return false; } - /** - * Update a file. - * - * @param string $path - * @param string $contents - * @param Config $config Config object - * - * @return array|false false on failure file meta data on success - */ - final public function update($path, $contents, Config $config) - { - return $this->write($path, $contents, $config); - } - /** * Write a new file. * diff --git a/src/NextcloudContacts.php b/src/NextcloudContacts.php index b0bcfd4..bcfdf24 100644 --- a/src/NextcloudContacts.php +++ b/src/NextcloudContacts.php @@ -85,7 +85,7 @@ final public function copy($path, $newpath) * * @throws BadRequest */ - final public function createDir($addressBookName, Config $config) + final public function createDirectory($addressBookName, Config $config) { $addressBookId = $this->cardDavBackend->createAddressBook($this->principalUri, $addressBookName, array()); if ($addressBookId !== null) { @@ -116,7 +116,7 @@ final public function delete($path) * * @return bool */ - final public function deleteDir($addressBook) + final public function deleteDirectory($addressBook) { $addressBookId = $this->getAddressBookId($addressBook); if (!$addressBookId) { @@ -167,7 +167,7 @@ final public function getMetadata($path) * * @return array|false */ - final public function getMimeType($path) + final public function mimeType($path) { return $this->getMetadata($path); } @@ -179,7 +179,7 @@ final public function getMimeType($path) * * @return array|false */ - final public function getSize($path) + final public function fileSize($path) { return $this->getMetadata($path); } @@ -191,7 +191,7 @@ final public function getSize($path) * * @return array|false */ - final public function getTimestamp($path) + final public function lastModified($path) { return $this->getMetadata($path); } @@ -203,7 +203,7 @@ final public function getTimestamp($path) * * @return array|false */ - final public function getVisibility($path) + final public function visibility($path) { return $this->getMetadata($path); } @@ -215,7 +215,7 @@ final public function getVisibility($path) * * @return bool */ - final public function has($path) + final public function fileExists($path) { if ($path === '.acl' && $this->defaultAcl) { return true; @@ -233,6 +233,18 @@ final public function has($path) } } + /** + * Check whether a directory exists. + * + * @param string $path + * + * @return bool + */ + final public function directoryExists($path) + { + return $this->fileExists($path); + } + /** * List contents of a directory. * @@ -294,7 +306,7 @@ final public function read($path) * * @return bool */ - final public function rename($path, $newpath) + final public function move($path, $newpath) { return false; } @@ -312,20 +324,6 @@ final public function setVisibility($path, $visibility) return false; } - /** - * Update a file. - * - * @param string $path - * @param string $contents - * @param Config $config Config object - * - * @return array|false false on failure file meta data on success - */ - final public function update($path, $contents, Config $config) - { - return $this->write($path, $contents, $config); - } - /** * Write a new file. * diff --git a/src/NextcloudContacts.php~ b/src/NextcloudContacts.php~ new file mode 100644 index 0000000..ef5dd41 --- /dev/null +++ b/src/NextcloudContacts.php~ @@ -0,0 +1,412 @@ +userId = $userId; + $this->principalUri = 'principals/users/' . $this->userId; + $this->defaultAcl = $defaultAcl; + + $principalBackend = new Principal( + OC::$server->getUserManager(), + OC::$server->getGroupManager(), + OC::$server->getShareManager(), + OC::$server->getUserSession(), + OC::$server->getAppManager(), + OC::$server->query(ProxyMapper::class), + OC::$server->getConfig(), + 'principals/' + ); + $db = OC::$server->getDatabaseConnection(); + $userManager = OC::$server->getUserManager(); + $dispatcher = OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class); + $legacyDispatcher = OC::$server->getEventDispatcher(); + + $this->cardDavBackend = new CardDavBackend( + $db, + $principalBackend, + $userManager, + OC::$server->getGroupManager(), + $dispatcher, + $legacyDispatcher, + true + ); + } + + /** + * Copy a file. + * + * @param string $path + * @param string $newpath + * + * @return bool + */ + final public function copy($path, $newpath) + { + // FIXME: Implementation + return false; + } + + /** + * Create an address book. + * + * @param string $addressBookName address book name + * @param Config $config + * + * @return array|false + * + * @throws BadRequest + */ + final public function createDirectory($addressBookName, Config $config) + { + $addressBookId = $this->cardDavBackend->createAddressBook($this->principalUri, $addressBookName, array()); + if ($addressBookId !== null) { + return ['path' => $addressBookName, 'type' => 'dir']; + } + return false; + } + + /** + * Delete a card. + * + * @param string $path + * + * @return bool + */ + final public function delete($path) + { + list($addressBook, $filename) = $this->splitPath($path); + $addressBookId = $this->getAddressBookId($addressBook); + $this->cardDavBackend->deleteCard($addressBookId, $filename); + return true; + } + + /** + * Delete an addressBook. + * + * @param string $addressBook + * + * @return bool + */ + final public function deleteDirectory($addressBook) + { + $addressBookId = $this->getAddressBookId($addressBook); + if (!$addressBookId) { + return false; + } + + $this->cardDavBackend->deleteAddressBook($addressBookId); + return true; + } + + private function getAddressBookId($path) { + $path = explode('/', $path); + if (count($path) === 1) { + $addressBook = $this->cardDavBackend->getAddressBooksByUri($this->principalUri, $path[0]); + if ($addressBook) { + return $addressBook['id']; + } + } + + return null; + } + + /** + * Get all the meta data of a file or directory. + * + * @param string $path + * + * @return array|false + */ + final public function getMetadata($path) + { + $addressBookId = $this->getAddressBookId($path); + if ($addressBookId !== null) { + $addressBook = $this->cardDavBackend->getAddressBookById($addressBookId); + return $this->normalizeAddressBook($addressBook); + } else { + list($addressBook, $filename) = $this->splitPath($path); + $addressBookId = $this->getAddressBookId($addressBook); + $card = $this->cardDavBackend->getCard($addressBookId, $filename); + return $this->normalizeCard($card, $addressBook); + } + } + + /** + * Get the mimetype of a file. + * + * @param string $path + * + * @return array|false + */ + final public function mimeType($path) + { + return $this->getMetadata($path); + } + + /** + * Get the size of a file. + * + * @param string $path + * + * @return array|false + */ + final public function fileSize($path) + { + return $this->getMetadata($path); + } + + /** + * Get the timestamp of a file. + * + * @param string $path + * + * @return array|false + */ + final public function lastModified($path) + { + return $this->getMetadata($path); + } + + /** + * Get the visibility of a file. + * + * @param string $path + * + * @return array|false + */ + final public function visibility($path) + { + return $this->getMetadata($path); + } + + /** + * Check whether a file exists. + * + * @param string $path + * + * @return bool + */ + final public function fileExists($path) + { + if ($path === '.acl' && $this->defaultAcl) { + return true; + } + + $addressBookId = $this->getAddressBookId($path); + if ($addressBookId !== null) { + return true; + } else { + list($addressBook, $filename) = $this->splitPath($path); + $addressBookId = $this->getAddressBookId($addressBook); + $card = $this->cardDavBackend->getCard($addressBookId, $filename); + + return is_array($card); + } + } + + /** + * Check whether a directory exists. + * + * @param string $path + * + * @return bool + */ + final public function directoryExists($path) + { + return $this->fileExists($path); + } + + /** + * List contents of a directory. + * + * @param string $directory + * @param bool $recursive + * + * @return array + */ + final public function listContents($directory = '', $recursive = false) + { + if ($directory === '') { + $addressBooks = $this->cardDavBackend->getAddressBooksForUser($this->userId); + + return array_map(function ($addressBook) { + return $this->normalizeAddressBook($addressBook); + }, $addressBooks); + } else { + $directory = basename($directory); + + $addressBook = $this->cardDavBackend->getAddressBooksByUri($this->principalUri, $directory); + $cards = $this->cardDavBackend->getCards($addressBook['id']); + + $contents = []; + foreach ($cards as $card) { + $contents[] = $this->cardDavBackend->getCard($addressBook['id'], $card['uri']); + } + + return array_map(function($card) use ($directory) { + return $this->normalizeCard($card, $directory); + }, $contents); + } + } + + /** + * Read a file. + * + * @param string $path + * + * @return array|false + */ + final public function read($path) + { + if ($path === '.acl' && $this->defaultAcl) { + return $this->normalizeAcl($this->defaultAcl); + } + + list($addressBook, $filename) = $this->splitPath($path); + $addressBookId = $this->getAddressBookId($addressBook); + $card = $this->cardDavBackend->getCard($addressBookId, $filename); + + return $this->normalizeCard($card, $addressBook); + } + + /** + * Rename a file. + * + * @param string $path + * @param string $newpath + * + * @return bool + */ + final public function move($path, $newpath) + { + return false; + } + + /** + * Set the visibility for a file. + * + * @param string $path + * @param string $visibility + * + * @return array|false file meta data + */ + final public function setVisibility($path, $visibility) + { + return false; + } + + /** + * Write a new file. + * + * @param string $path + * @param string $contents + * @param Config $config Config object + * + * @return array|false false on failure file meta data on success + * + * @throws BadRequest + */ + final public function write($path, $contents, Config $config) + { + list($addressBook, $filename) = $this->splitPath($path); + $addressBookId = $this->getAddressBookId($addressBook); + if ($this->has($path)) { + $this->cardDavBackend->updateCard($addressBookId, $filename, $contents); + } else { + $this->cardDavBackend->createCard($addressBookId, $filename, $contents); + } + return true; + } + + private function normalizeAcl($acl) { + return [ + 'basename' => '.acl', + 'contents' => $acl, + 'mimetype' => 'text/turtle', + 'path' => '.acl', + 'size' => strlen($acl), + 'timestamp' => 0, + 'type' => 'file', + 'visibility' => 'public', + ]; + } + + private function normalizeCard($card, $basePath) { + if ( ! is_array($card)) { + return false; + } + + return [ + 'basename' => $card['uri'], + 'contents' => $card['carddata'], + 'mimetype' => 'text/vcard', + 'path' => $basePath . '/' . $card['uri'], + 'size' => $card['size'], + 'timestamp' => $card['lastmodified'], + 'type' => 'file', + 'visibility' => 'public', + ]; + } + + private function normalizeAddressBook($addressBook) + { + return [ + 'basename' => basename($addressBook['uri']), + 'mimetype' => 'directory', + 'path' => $addressBook['uri'], + 'size' => 0, + 'timestamp' => 0, + 'type' => 'dir', + // @FIXME: Use $node->getPermissions() to set private or public + // as soon as we figure out what Nextcloud permissions mean in this context + 'visibility' => 'public', + /*/ + 'CreationTime' => $node->getCreationTime(), + 'Etag' => $node->getEtag(), + 'Owner' => $node->getOwner(), + /*/ + ]; + } + + /** + * @param string $path + * + * @return string[] + */ + private function splitPath(string $path) + { + return [ + dirname($path), + basename($path) + ]; + } +} diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index 222af8b..f4e683a 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -52,7 +52,7 @@ final public function copy($path, $newpath) * * @return array|false */ - final public function createDir($dirName, Config $config) + final public function createDirectory($dirName, Config $config) { return false; } @@ -76,7 +76,7 @@ final public function delete($path) * * @return bool */ - final public function deleteDir($dirName) + final public function deleteDirectory($dirName) { return false; } @@ -100,7 +100,7 @@ final public function getMetadata($path) * * @return array|false */ - final public function getMimeType($path) + final public function mimeType($path) { return $this->getMetadata($path); } @@ -112,7 +112,7 @@ final public function getMimeType($path) * * @return array|false */ - final public function getSize($path) + final public function fileSize($path) { return $this->getMetadata($path); } @@ -124,7 +124,7 @@ final public function getSize($path) * * @return array|false */ - final public function getTimestamp($path) + final public function lastModified($path) { return $this->getMetadata($path); } @@ -136,7 +136,7 @@ final public function getTimestamp($path) * * @return array|false */ - final public function getVisibility($path) + final public function visibility($path) { return $this->getMetadata($path); } @@ -148,7 +148,7 @@ final public function getVisibility($path) * * @return bool */ - final public function has($path) + final public function fileExists($path) { if ($path === '.acl' && $this->defaultAcl) { return true; @@ -160,6 +160,18 @@ final public function has($path) return false; } + /** + * Check whether a directory exists. + * + * @param string $path + * + * @return bool + */ + final public function directoryExists($path) + { + return $this->fileExists($path); + } + /** * List contents of a directory. * @@ -201,7 +213,7 @@ final public function read($path) * * @return bool */ - final public function rename($path, $newpath) + final public function move($path, $newpath) { return false; } @@ -219,20 +231,6 @@ final public function setVisibility($path, $visibility) return false; } - /** - * Update a file. - * - * @param string $path - * @param string $contents - * @param Config $config Config object - * - * @return array|false false on failure file meta data on success - */ - final public function update($path, $contents, Config $config) - { - return $this->write($path, $contents, $config); - } - /** * Write a new file. * From 9ef916b0a6d702ec705dabe16a82815688ff9b92 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 28 Sep 2026 14:18:01 +0200 Subject: [PATCH 02/16] update to flysystem3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 30f1911..3d447f2 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "require": { "php": "^8.0", "ext-mbstring": "*", - "league/flysystem": "^1.0" + "league/flysystem": "^3.0" }, "require-dev": { "nextcloud/server": "*", From 783a3b51bb61b707a415faa17f2f2cf4c38250c1 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 28 Sep 2026 14:19:17 +0200 Subject: [PATCH 03/16] bump to 8.3 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3d447f2..f684b66 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "sort-packages": true, "bin-dir": "./bin", "platform": { - "php": "8.0", + "php": "8.3", "ext-mbstring": "0.0.0" } }, @@ -42,7 +42,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.3", "ext-mbstring": "*", "league/flysystem": "^3.0" }, From 5eec7dadcaaa2194e11a0c9bfad1a91b74a616a7 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 28 Sep 2026 14:20:32 +0200 Subject: [PATCH 04/16] drop php 8.0, 8.1, 8.2 and add 8.4 --- .github/workflows/php.yml | 8 +-- .github/workflows/php.yml~ | 136 +++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/php.yml~ diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 64da6d6..fbf453d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -74,10 +74,8 @@ jobs: fail-fast: false matrix: php: - - '8.0' # from 2020-11 to 2022-11 (2023-11) - - '8.1' # from 2021-11 to 2023-11 (2025-12) - - '8.2' # from 2022-12 to 2024-12 (2026-12) - '8.3' # from 2023-11 to 2025-12 (2027-12) + - '8.4' steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 @@ -118,10 +116,8 @@ jobs: fail-fast: false matrix: php: - - '8.0' # from 2020-11 to 2022-11 (2023-11) - - '8.1' # from 2021-11 to 2023-11 (2025-12) - - '8.2' # from 2022-12 to 2024-12 (2026-12) - '8.3' # from 2023-11 to 2025-12 (2027-12) + - '8.4' steps: - uses: actions/checkout@v4 - uses: docker://pipelinecomponents/php-codesniffer diff --git a/.github/workflows/php.yml~ b/.github/workflows/php.yml~ new file mode 100644 index 0000000..e91dffd --- /dev/null +++ b/.github/workflows/php.yml~ @@ -0,0 +1,136 @@ +--- +name: PHP Quality Assistance + +on: + # This event occurs when there is activity on a pull request. The workflow + # will be run against the commits, after merge to the target branch (main). + pull_request: + paths: + - '**.php' + - '.config/phpcs.xml.dist' + - '.config/phpunit.xml.dist' + - '.github/workflows/php.yml' + - 'composer.json' + - 'composer.lock' + branches: [ main ] + types: [ opened, reopened, synchronize ] + # This event occurs when there is a push to the repository. + push: + paths: + - '**.php' + - '.config/phpcs.xml.dist' + - '.config/phpunit.xml.dist' + - '.github/workflows/php.yml' + - 'composer.json' + - 'composer.lock' + # Allow manually triggering the workflow. + workflow_dispatch: + + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + # Needed to allow the "concurrency" section to cancel a workflow run. + actions: write + +jobs: + # 01.preflight.php.lint-syntax.yml + lint-php-syntax: + name: PHP Syntax Linting + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: docker://pipelinecomponents/php-linter + with: + args: >- + parallel-lint + --exclude .git + --exclude vendor + --no-progress + . + # 01.quality.php.validate.dependencies-file.yml + validate-dependencies-file: + name: Validate dependencies file + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - run: >- + composer validate + --check-lock + --no-plugins + --no-scripts + --strict + # 02.test.php.test-unit.yml + php-unittest: + name: PHP Unit Tests + needs: + - lint-php-syntax + - validate-dependencies-file + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + php: +# - '8.0' # from 2020-11 to 2022-11 (2023-11) +# - '8.1' # from 2021-11 to 2023-11 (2025-12) +# - '8.2' # from 2022-12 to 2024-12 (2026-12) + - '8.3' # from 2023-11 to 2025-12 (2027-12) + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + coverage: xdebug + ini-values: error_reporting=E_ALL, display_errors=On + php-version: ${{ matrix.php }} + - name: Install and Cache Composer dependencies + uses: "ramsey/composer-install@v2" + env: + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' + - run: bin/phpunit --configuration .config/phpunit.xml.dist + # 03.quality.php.scan.dependencies-vulnerabilities.yml + scan-dependencies-vulnerabilities: + name: Scan Dependencies Vulnerabilities + needs: + - validate-dependencies-file + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Install and Cache Composer dependencies + uses: "ramsey/composer-install@v2" + env: + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' + - run: >- + composer audit + --abandoned=report + --no-dev + --no-plugins + --no-scripts + # 03.quality.php.lint-version-compatibility.yml + php-check-version-compatibility: + name: PHP Version Compatibility + needs: + - lint-php-syntax + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + php: +# - '8.0' # from 2020-11 to 2022-11 (2023-11) +# - '8.1' # from 2021-11 to 2023-11 (2025-12) +# - '8.2' # from 2022-12 to 2024-12 (2026-12) + - '8.3' # from 2023-11 to 2025-12 (2027-12) + steps: + - uses: actions/checkout@v4 + - uses: docker://pipelinecomponents/php-codesniffer + with: + args: >- + phpcs + -s + --extensions=php + --ignore='*vendor/*' + --runtime-set testVersion ${{ matrix.php }} + --standard=PHPCompatibility + . From 75f19a4e0b9134e47e9409f2f832422055f84a78 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 28 Sep 2026 14:20:55 +0200 Subject: [PATCH 05/16] remove backup file --- .github/workflows/php.yml~ | 136 ------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 .github/workflows/php.yml~ diff --git a/.github/workflows/php.yml~ b/.github/workflows/php.yml~ deleted file mode 100644 index e91dffd..0000000 --- a/.github/workflows/php.yml~ +++ /dev/null @@ -1,136 +0,0 @@ ---- -name: PHP Quality Assistance - -on: - # This event occurs when there is activity on a pull request. The workflow - # will be run against the commits, after merge to the target branch (main). - pull_request: - paths: - - '**.php' - - '.config/phpcs.xml.dist' - - '.config/phpunit.xml.dist' - - '.github/workflows/php.yml' - - 'composer.json' - - 'composer.lock' - branches: [ main ] - types: [ opened, reopened, synchronize ] - # This event occurs when there is a push to the repository. - push: - paths: - - '**.php' - - '.config/phpcs.xml.dist' - - '.config/phpunit.xml.dist' - - '.github/workflows/php.yml' - - 'composer.json' - - 'composer.lock' - # Allow manually triggering the workflow. - workflow_dispatch: - - -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - # Needed to allow the "concurrency" section to cancel a workflow run. - actions: write - -jobs: - # 01.preflight.php.lint-syntax.yml - lint-php-syntax: - name: PHP Syntax Linting - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - uses: docker://pipelinecomponents/php-linter - with: - args: >- - parallel-lint - --exclude .git - --exclude vendor - --no-progress - . - # 01.quality.php.validate.dependencies-file.yml - validate-dependencies-file: - name: Validate dependencies file - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - run: >- - composer validate - --check-lock - --no-plugins - --no-scripts - --strict - # 02.test.php.test-unit.yml - php-unittest: - name: PHP Unit Tests - needs: - - lint-php-syntax - - validate-dependencies-file - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - php: -# - '8.0' # from 2020-11 to 2022-11 (2023-11) -# - '8.1' # from 2021-11 to 2023-11 (2025-12) -# - '8.2' # from 2022-12 to 2024-12 (2026-12) - - '8.3' # from 2023-11 to 2025-12 (2027-12) - steps: - - uses: actions/checkout@v4 - - uses: shivammathur/setup-php@v2 - with: - coverage: xdebug - ini-values: error_reporting=E_ALL, display_errors=On - php-version: ${{ matrix.php }} - - name: Install and Cache Composer dependencies - uses: "ramsey/composer-install@v2" - env: - COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' - - run: bin/phpunit --configuration .config/phpunit.xml.dist - # 03.quality.php.scan.dependencies-vulnerabilities.yml - scan-dependencies-vulnerabilities: - name: Scan Dependencies Vulnerabilities - needs: - - validate-dependencies-file - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - name: Install and Cache Composer dependencies - uses: "ramsey/composer-install@v2" - env: - COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' - - run: >- - composer audit - --abandoned=report - --no-dev - --no-plugins - --no-scripts - # 03.quality.php.lint-version-compatibility.yml - php-check-version-compatibility: - name: PHP Version Compatibility - needs: - - lint-php-syntax - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - php: -# - '8.0' # from 2020-11 to 2022-11 (2023-11) -# - '8.1' # from 2021-11 to 2023-11 (2025-12) -# - '8.2' # from 2022-12 to 2024-12 (2026-12) - - '8.3' # from 2023-11 to 2025-12 (2027-12) - steps: - - uses: actions/checkout@v4 - - uses: docker://pipelinecomponents/php-codesniffer - with: - args: >- - phpcs - -s - --extensions=php - --ignore='*vendor/*' - --runtime-set testVersion ${{ matrix.php }} - --standard=PHPCompatibility - . From bc33cc60b22f583f4f4a7deb622cceaf85897c2c Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 15:06:00 +0200 Subject: [PATCH 06/16] align methods --- src/Nextcloud.php | 148 +++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 95 deletions(-) diff --git a/src/Nextcloud.php b/src/Nextcloud.php index 6eb32d5..4a7a02f 100644 --- a/src/Nextcloud.php +++ b/src/Nextcloud.php @@ -2,14 +2,15 @@ namespace Pdsinterop\Flysystem\Adapter; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\FileAttributes; use League\Flysystem\Config; use OCP\Files\Folder; /** * Filesystem adapter to access files in Nextcloud */ -class Nextcloud implements AdapterInterface +class Nextcloud implements FilesystemAdapter { /** @var Folder */ private $folder; @@ -24,20 +25,16 @@ final public function __construct(Folder $folder) * * @param string $path * @param string $newpath - * - * @return bool */ - final public function copy($path, $newpath) + final public function copy(string $path, string $newpath, Config $config): void { try { $node = $this->folder->get($path); } catch (\OCP\Files\NotFoundException $exception) { - return false; + return; } $node->copy($newpath); - - return true; } /** @@ -46,15 +43,11 @@ final public function copy($path, $newpath) * @param string $dirname directory name * @param Config $config * - * @return array|false - * * @throws \OCP\Files\NotPermittedException */ - final public function createDirectory($dirname, Config $config) + final public function createDirectory(string $dirname, Config $config): void { $this->folder->newFolder($dirname); - - return ['path' => $dirname, 'type' => 'dir']; } /** @@ -62,22 +55,18 @@ final public function createDirectory($dirname, Config $config) * * @param string $path * - * @return bool - * * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotPermittedException */ - final public function delete($path) + final public function delete(string $path): void { try { $node = $this->folder->get($path); } catch (\OCP\Files\NotFoundException $exception) { - return false; + return; } $node->delete(); - - return true; } /** @@ -85,27 +74,20 @@ final public function delete($path) * * @param string $dirname * - * @return bool - * * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotPermittedException */ - final public function deleteDirectory($dirname) + final public function deleteDirectory(string $dirname): void { - $result = false; - try { $node = $this->folder->get($dirname); } catch (\OCP\Files\NotFoundException $exception) { - return false; + return; } if ($this->isDirectory($node)) { $node->delete(); - $result = true; } - - return $result; } /** @@ -113,15 +95,22 @@ final public function deleteDirectory($dirname) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes * * @throws \OCP\Files\InvalidPathException */ - final public function getMetadata($path) + final public function getAttributes(string $path): FileAttributes { try { $node = $this->folder->get($path); - return $this->normalizeNodeInfo($node); + $metaData = $this->normalizeNodeInfo($node); + return new FileAttributes( + $path, + $metaData['size'], + $metaData['visibility'], + $metaData['timestamp'], + $metaData['mimetype'] + ); } catch (\OCP\Files\NotFoundException $exception) { return false; } @@ -132,11 +121,11 @@ final public function getMetadata($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function getMimeType($path) + final public function mimeType(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -144,11 +133,11 @@ final public function getMimeType($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function fileSize($path) + final public function fileSize(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -156,11 +145,11 @@ final public function fileSize($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function lastModified($path) + final public function lastModified(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -168,11 +157,11 @@ final public function lastModified($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function visibility($path) + final public function visibility(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -180,9 +169,9 @@ final public function visibility($path) * * @param string $path * - * @return array|bool|null + * @return bool */ - final public function fileExists($path) + final public function fileExists(string $path): bool { return $this->folder->nodeExists($path); } @@ -192,9 +181,9 @@ final public function fileExists($path) * * @param string $path * - * @return array|bool|null + * @return bool */ - final public function directoryExists($path) + final public function directoryExists(string $path): bool { return $this->folder->nodeExists($path); } @@ -210,7 +199,7 @@ final public function directoryExists($path) * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotFoundException */ - final public function listContents($directory = '', $recursive = false) + final public function listContents(string $directory = '', bool $recursive = false): iterable { $result = []; @@ -236,11 +225,11 @@ final public function listContents($directory = '', $recursive = false) * * @param string $path * - * @return array|false + * @return string * * @throws \OCP\Files\InvalidPathException */ - final public function read($path) + final public function read(string $path): string { $result = false; @@ -251,12 +240,9 @@ final public function read($path) } if (method_exists($node, 'getContent')) { - $result = $this->normalizeNodeInfo($node, [ - 'contents' => $node->getContent(), - ]); + return $node->getContent(); } - - return $result; + // FIXME: throw exception } /** @@ -266,7 +252,7 @@ final public function read($path) * * @return array|false */ - final public function readStream($path) + final public function readStream(string $path) { $result = false; @@ -277,12 +263,9 @@ final public function readStream($path) } if (method_exists($node, 'fopen')) { - $result = $this->normalizeNodeInfo($node, [ - 'stream' => $node->fopen('rb'), - ]); + return $node->fopen('rb'); } - - return $result; + // FIXME: throw exception } /** @@ -291,21 +274,17 @@ final public function readStream($path) * @param string $path * @param string $newpath * - * @return bool - * * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotPermittedException * @throws \OCP\Lock\LockedException */ - final public function move($path, $newpath) + final public function move(string $path, string $newpath): void { try { $this->folder->get($path)->move($newpath); } catch (\OCP\Files\NotFoundException $exception) { - return false; + return; } - - return true; } /** @@ -313,12 +292,10 @@ final public function move($path, $newpath) * * @param string $path * @param string $visibility - * - * @return array|false file meta data */ - final public function setVisibility($path, $visibility) + final public function setVisibility(string $path, string $visibility): void { - return false; + // FIXME: implement something here } /** @@ -328,11 +305,9 @@ final public function setVisibility($path, $visibility) * @param string $contents * @param Config $config Config object * - * @return array|false false on failure file meta data on success - * * @throws \OCP\Files\InvalidPathException */ - final public function write($path, $contents, Config $config) + final public function write(string $path, string $contents, Config $config): void { $result = true; @@ -341,10 +316,6 @@ final public function write($path, $contents, Config $config) $node = $this->folder->get($path); if (method_exists($node, 'putContent')) { $node->putContent($contents); - - $result = $this->normalizeNodeInfo($node, [ - 'contents' => $node->getContent(), - ]); } } else { $filename = basename($path); @@ -356,10 +327,8 @@ final public function write($path, $contents, Config $config) $node->newFile($filename, $contents); } } catch(\Exception $e) { - return false; + // FIXME: throw? } - - return $result; } /** @@ -369,18 +338,14 @@ final public function write($path, $contents, Config $config) * @param resource $resource * @param Config $config Config object * - * @return array|false false on failure file meta data on success - * * @throws \OCP\Files\NotPermittedException */ - final public function writeStream($path, $resource, Config $config) + final public function writeStream($path, $resource, Config $config): void { - $result = false; - try { $node = $this->folder->get($path); } catch (\OCP\Files\NotFoundException $exception) { - return false; + return; } if (method_exists($node, 'fopen')) { @@ -396,16 +361,9 @@ final public function writeStream($path, $resource, Config $config) if (stream_copy_to_stream($resource, $stream) === false) { fclose($stream); - return false; + return; } - - $result = [ - 'type' => 'file', - 'path' => $path, - ]; } - - return $result; } /** From 1402f829e0bb9ea7d46851438dd8b0d3d5118771 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 15:15:22 +0200 Subject: [PATCH 07/16] typofixes --- src/Nextcloud.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Nextcloud.php b/src/Nextcloud.php index 4a7a02f..9fbe84b 100644 --- a/src/Nextcloud.php +++ b/src/Nextcloud.php @@ -25,6 +25,7 @@ final public function __construct(Folder $folder) * * @param string $path * @param string $newpath + * @param Config $config */ final public function copy(string $path, string $newpath, Config $config): void { @@ -309,8 +310,6 @@ final public function setVisibility(string $path, string $visibility): void */ final public function write(string $path, string $contents, Config $config): void { - $result = true; - try { if ($this->folder->nodeExists($path)) { $node = $this->folder->get($path); From 7c6ce4452c42e97ee48cca6b528eadfa8e6a66aa Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 15:15:30 +0200 Subject: [PATCH 08/16] align methods --- src/NextcloudProfile.php | 97 +++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index f4e683a..1c9cfe6 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -3,14 +3,15 @@ namespace Pdsinterop\Flysystem\Adapter; use League\Flysystem\Adapter\Polyfill\StreamedTrait; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\FileAttributes; use League\Flysystem\Config; use OCA\Solid\ServerConfig; /** * Filesystem adapter to access profile information from Nextcloud */ -class NextcloudProfile implements AdapterInterface +class NextcloudProfile implements FilesystemAdapter { use StreamedTrait; @@ -36,10 +37,9 @@ final public function __construct($userId, $profile, $defaultAcl, $config) * * @param string $path * @param string $newpath - * - * @return bool + * @param Config $config */ - final public function copy($path, $newpath) + final public function copy(string $path, string $newpath, Config $config): void { // FIXME: Implementation return false; @@ -52,33 +52,29 @@ final public function copy($path, $newpath) * * @return array|false */ - final public function createDirectory($dirName, Config $config) + final public function createDirectory(string $dirname, Config $config): void { - return false; + return; } /** * Delete a file. * * @param string $path - * - * @return bool */ - final public function delete($path) + final public function delete(string $path): void { - return false; + return; } /** * Delete a dir. * * @param string $dirName - * - * @return bool */ - final public function deleteDirectory($dirName) + final public function deleteDirectory(string $dirname): void { - return false; + return; } /** @@ -86,11 +82,18 @@ final public function deleteDirectory($dirName) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function getMetadata($path) + final public function getAttributes(string $path): FileAttributes { - return $this->normalizeProfile(); + $metaData = $this->normalizeProfile(); + return new FileAttributes( + $path, + $metaData['size'], + $metaData['visibility'], + $metaData['timestamp'], + $metaData['mimetype'] + ); } /** @@ -98,11 +101,11 @@ final public function getMetadata($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function mimeType($path) + final public function mimeType(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -110,11 +113,11 @@ final public function mimeType($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function fileSize($path) + final public function fileSize(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -122,11 +125,11 @@ final public function fileSize($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function lastModified($path) + final public function lastModified(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -134,11 +137,11 @@ final public function lastModified($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function visibility($path) + final public function visibility(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -148,7 +151,7 @@ final public function visibility($path) * * @return bool */ - final public function fileExists($path) + final public function fileExists(string $path): bool { if ($path === '.acl' && $this->defaultAcl) { return true; @@ -167,7 +170,7 @@ final public function fileExists($path) * * @return bool */ - final public function directoryExists($path) + final public function directoryExists(string $path): bool { return $this->fileExists($path); } @@ -180,7 +183,7 @@ final public function directoryExists($path) * * @return array */ - final public function listContents($directory = '', $recursive = false) + final public function listContents(string $directory = '', bool $recursive = false): iterable { return [ $this->normalizeProfile() @@ -192,17 +195,17 @@ final public function listContents($directory = '', $recursive = false) * * @param string $path * - * @return array|false + * @return string */ - final public function read($path) + final public function read(string $path): string { if ($path === '.acl' && $this->defaultAcl) { - return $this->normalizeAcl($this->defaultAcl); + return $this->defaultAcl; } if ($path === 'card') { - return $this->normalizeProfile(); + return $this->profile; } - return false; + return ''; } /** @@ -210,12 +213,10 @@ final public function read($path) * * @param string $path * @param string $newpath - * - * @return bool */ - final public function move($path, $newpath) + final public function move(string $path, string $newpath): void { - return false; + return; } /** @@ -223,12 +224,10 @@ final public function move($path, $newpath) * * @param string $path * @param string $visibility - * - * @return array|false file meta data */ - final public function setVisibility($path, $visibility) + final public function setVisibility(string $path, string $visibility): void { - return false; + return; } /** @@ -237,16 +236,12 @@ final public function setVisibility($path, $visibility) * @param string $path * @param string $contents * @param Config $config Config object - * - * @return array|false false on failure file meta data on success */ - final public function write($path, $contents, Config $config) + final public function write(string $path, string $contents, Config $config): void { if ($path === 'card') { $this->config->setProfileData($this->userId, $contents); - return true; } - return false; } private function normalizeAcl($acl) { From 9c6558e8f5921a1140ed21d394f5dea0bb0b801a Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 15:26:52 +0200 Subject: [PATCH 09/16] align methods --- src/NextcloudCalendar.php | 97 ++++----- src/NextcloudContacts.php | 101 +++++---- src/NextcloudContacts.php~ | 412 ------------------------------------- 3 files changed, 88 insertions(+), 522 deletions(-) delete mode 100644 src/NextcloudContacts.php~ diff --git a/src/NextcloudCalendar.php b/src/NextcloudCalendar.php index 60b360e..c53bfe2 100644 --- a/src/NextcloudCalendar.php +++ b/src/NextcloudCalendar.php @@ -70,13 +70,11 @@ final public function __construct($userId, $defaultAcl) * * @param string $path * @param string $newpath - * - * @return bool */ - final public function copy($path, $newpath) + final public function copy(string $path, string $newpath): void { // FIXME: Implementation - return false; + return; } /** @@ -85,50 +83,38 @@ final public function copy($path, $newpath) * @param string $calendarName calendar name * @param Config $config * - * @return array|false - * * @throws Exception */ - final public function createDirectory($calendarName, Config $config) + final public function createDirectory(string $calendarName, Config $config): void { $calendarId = $this->calDavBackend->createCalendar($this->principalUri, $calendarName, []); - if ($calendarId !== null) { - return ['path' => $calendarName, 'type' => 'dir']; - } - return false; } /** * Delete a calendar item. * * @param string $path - * - * @return bool */ - final public function delete($path) + final public function delete(string $path): void { list($calendar, $filename) = $this->splitPath($path); $calendarId = $this->getCalendarId($calendar); $this->calDavBackend->deleteCalendarObject($calendarId, $filename); - return true; } /** * Delete a calendar. * * @param string $calendar - * - * @return bool */ - final public function deleteDirectory($calendar) + final public function deleteDirectory(string $calendar): void { $calendarId = $this->getCalendarId($calendar); if (!$calendarId) { - return false; + return; } $this->calDavBackend->deleteCalendar($calendarId); - return true; } private function getCalendarId($path) { @@ -148,20 +134,27 @@ private function getCalendarId($path) { * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function getMetadata($path) + final public function getAttributes(string $path): FileAttributes { $calendarId = $this->getCalendarId($path); if ($calendarId !== null) { $calendar = $this->calDavBackend->getCalendarById($calendarId); - return $this->normalizeCalendar($calendar); + $metaData = $this->normalizeCalendar($calendar); } else { list($calendar, $filename) = $this->splitPath($path); $calendarId = $this->getCalendarId($calendar); $calendarItem = $this->calDavBackend->getCalendarObject($calendarId, $filename); - return $this->normalizeCalendarItem($calendarItem, $calendar); + $metaData = $this->normalizeCalendarItem($calendarItem, $calendar); } + return new FileAttributes( + $path, + $metaData['size'], + $metaData['visibility'], + $metaData['timestamp'], + $metaData['mimetype'] + ); } /** @@ -169,11 +162,11 @@ final public function getMetadata($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function mimeType($path) + final public function mimeType(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -181,11 +174,11 @@ final public function mimeType($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function fileSize($path) + final public function fileSize(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -193,11 +186,11 @@ final public function fileSize($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function lastModified($path) + final public function lastModified(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -205,11 +198,11 @@ final public function lastModified($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function visibility($path) + final public function visibility(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -219,7 +212,7 @@ final public function visibility($path) * * @return bool */ - final public function fileExists($path) + final public function fileExists(string $path): bool { if ($path === '.acl' && $this->defaultAcl) { return true; @@ -237,7 +230,7 @@ final public function fileExists($path) } } - final public function directoryExists($path) + final public function directoryExists(string $path): bool { return $this->fileExists($path); } @@ -250,7 +243,7 @@ final public function directoryExists($path) * * @return array */ - final public function listContents($directory = '', $recursive = false) + final public function listContents(string $directory = '', bool $recursive = false): iterable { if ($directory === '') { $calendars = $this->calDavBackend->getCalendarsForUser($this->userId); @@ -280,19 +273,18 @@ final public function listContents($directory = '', $recursive = false) * * @param string $path * - * @return array|false + * @return string */ - final public function read($path) + final public function read(string $path): string { if ($path === '.acl' && $this->defaultAcl) { - return $this->normalizeAcl($this->defaultAcl); + return $this->defaultAcl; } list($calendar, $filename) = $this->splitPath($path); $calendarId = $this->getCalendarId($calendar); $calendarItem = $this->calDavBackend->getCalendarObject($calendarId, $filename); - - return $this->normalizeCalendarItem($calendarItem, $calendar); + return $calendarItem['calendardata']; } /** @@ -300,12 +292,10 @@ final public function read($path) * * @param string $path * @param string $newpath - * - * @return bool */ - final public function move($path, $newpath) + final public function move(string $path, string $newpath): void { - return false; + return; } /** @@ -313,12 +303,10 @@ final public function move($path, $newpath) * * @param string $path * @param string $visibility - * - * @return array|false file meta data */ - final public function setVisibility($path, $visibility) + final public function setVisibility(string $path, string $visibility): void { - return false; + return; } /** @@ -328,11 +316,9 @@ final public function setVisibility($path, $visibility) * @param string $contents * @param Config $config Config object * - * @return array|false false on failure file meta data on success - * * @throws BadRequest */ - final public function write($path, $contents, Config $config) + final public function write(string $path, string $contents, Config $config): void { list($calendar, $filename) = $this->splitPath($path); $calendarId = $this->getCalendarId($calendar); @@ -341,7 +327,6 @@ final public function write($path, $contents, Config $config) } else { $this->calDavBackend->createCalendarObject($calendarId, $filename, $contents); } - return true; } private function normalizeAcl($acl) { diff --git a/src/NextcloudContacts.php b/src/NextcloudContacts.php index bcfdf24..56d6737 100644 --- a/src/NextcloudContacts.php +++ b/src/NextcloudContacts.php @@ -3,7 +3,8 @@ namespace Pdsinterop\Flysystem\Adapter; use League\Flysystem\Adapter\Polyfill\StreamedTrait; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\FileAttributes; use League\Flysystem\Config; use OC; @@ -16,7 +17,7 @@ /** * Filesystem adapter to access contacts information from Nextcloud */ -class NextcloudContacts implements AdapterInterface +class NextcloudContacts implements FilesystemAdapter { use StreamedTrait; @@ -66,13 +67,12 @@ final public function __construct($userId, $defaultAcl) * * @param string $path * @param string $newpath - * - * @return bool + * @param Config $config */ - final public function copy($path, $newpath) + final public function copy(string $path, string $newpath, Config $config): void { // FIXME: Implementation - return false; + return; } /** @@ -81,50 +81,38 @@ final public function copy($path, $newpath) * @param string $addressBookName address book name * @param Config $config * - * @return array|false - * * @throws BadRequest */ - final public function createDirectory($addressBookName, Config $config) + final public function createDirectory(string $addressBookName, Config $config): void { - $addressBookId = $this->cardDavBackend->createAddressBook($this->principalUri, $addressBookName, array()); - if ($addressBookId !== null) { - return ['path' => $addressBookName, 'type' => 'dir']; - } - return false; + $this->cardDavBackend->createAddressBook($this->principalUri, $addressBookName, array()); } /** * Delete a card. * * @param string $path - * - * @return bool */ - final public function delete($path) + final public function delete(string $path): void { list($addressBook, $filename) = $this->splitPath($path); $addressBookId = $this->getAddressBookId($addressBook); $this->cardDavBackend->deleteCard($addressBookId, $filename); - return true; } /** * Delete an addressBook. * * @param string $addressBook - * - * @return bool */ - final public function deleteDirectory($addressBook) + final public function deleteDirectory(string $addressBook): void { $addressBookId = $this->getAddressBookId($addressBook); if (!$addressBookId) { - return false; + return; } $this->cardDavBackend->deleteAddressBook($addressBookId); - return true; } private function getAddressBookId($path) { @@ -144,20 +132,27 @@ private function getAddressBookId($path) { * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function getMetadata($path) + final public function getAttributes(string $path): FileAttributes { $addressBookId = $this->getAddressBookId($path); if ($addressBookId !== null) { $addressBook = $this->cardDavBackend->getAddressBookById($addressBookId); - return $this->normalizeAddressBook($addressBook); + $metaData = $this->normalizeAddressBook($addressBook); } else { list($addressBook, $filename) = $this->splitPath($path); $addressBookId = $this->getAddressBookId($addressBook); $card = $this->cardDavBackend->getCard($addressBookId, $filename); - return $this->normalizeCard($card, $addressBook); + $metaData = $this->normalizeCard($card, $addressBook); } + return new FileAttributes( + $path, + $metaData['size'], + $metaData['visibility'], + $metaData['timestamp'], + $metaData['mimetype'] + ); } /** @@ -165,11 +160,11 @@ final public function getMetadata($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function mimeType($path) + final public function mimeType(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -177,11 +172,11 @@ final public function mimeType($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function fileSize($path) + final public function fileSize(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -189,11 +184,11 @@ final public function fileSize($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function lastModified($path) + final public function lastModified(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } /** @@ -201,13 +196,14 @@ final public function lastModified($path) * * @param string $path * - * @return array|false + * @return \League\Flysystem\FileAttributes */ - final public function visibility($path) + final public function visibility(string $path): FileAttributes { - return $this->getMetadata($path); + return $this->getAttributes($path); } + /** * Check whether a file exists. * @@ -215,7 +211,7 @@ final public function visibility($path) * * @return bool */ - final public function fileExists($path) + final public function fileExists(string $path): bool { if ($path === '.acl' && $this->defaultAcl) { return true; @@ -240,7 +236,7 @@ final public function fileExists($path) * * @return bool */ - final public function directoryExists($path) + final public function directoryExists(string $path): bool { return $this->fileExists($path); } @@ -253,7 +249,7 @@ final public function directoryExists($path) * * @return array */ - final public function listContents($directory = '', $recursive = false) + final public function listContents(string $directory = '', bool $recursive = false): iterable { if ($directory === '') { $addressBooks = $this->cardDavBackend->getAddressBooksForUser($this->userId); @@ -285,17 +281,16 @@ final public function listContents($directory = '', $recursive = false) * * @return array|false */ - final public function read($path) + final public function read(string $path): string { if ($path === '.acl' && $this->defaultAcl) { - return $this->normalizeAcl($this->defaultAcl); + return $this->defaultAcl; } list($addressBook, $filename) = $this->splitPath($path); $addressBookId = $this->getAddressBookId($addressBook); $card = $this->cardDavBackend->getCard($addressBookId, $filename); - - return $this->normalizeCard($card, $addressBook); + return $card['carddata']; } /** @@ -303,12 +298,10 @@ final public function read($path) * * @param string $path * @param string $newpath - * - * @return bool */ - final public function move($path, $newpath) + final public function move(string $path, string $newpath): void { - return false; + return; } /** @@ -319,9 +312,9 @@ final public function move($path, $newpath) * * @return array|false file meta data */ - final public function setVisibility($path, $visibility) + final public function setVisibility(string $path, string $visibility): void { - return false; + return; } /** @@ -335,7 +328,7 @@ final public function setVisibility($path, $visibility) * * @throws BadRequest */ - final public function write($path, $contents, Config $config) + final public function write(string $path, string $contents, Config $config): void { list($addressBook, $filename) = $this->splitPath($path); $addressBookId = $this->getAddressBookId($addressBook); @@ -344,7 +337,7 @@ final public function write($path, $contents, Config $config) } else { $this->cardDavBackend->createCard($addressBookId, $filename, $contents); } - return true; + return; } private function normalizeAcl($acl) { diff --git a/src/NextcloudContacts.php~ b/src/NextcloudContacts.php~ deleted file mode 100644 index ef5dd41..0000000 --- a/src/NextcloudContacts.php~ +++ /dev/null @@ -1,412 +0,0 @@ -userId = $userId; - $this->principalUri = 'principals/users/' . $this->userId; - $this->defaultAcl = $defaultAcl; - - $principalBackend = new Principal( - OC::$server->getUserManager(), - OC::$server->getGroupManager(), - OC::$server->getShareManager(), - OC::$server->getUserSession(), - OC::$server->getAppManager(), - OC::$server->query(ProxyMapper::class), - OC::$server->getConfig(), - 'principals/' - ); - $db = OC::$server->getDatabaseConnection(); - $userManager = OC::$server->getUserManager(); - $dispatcher = OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class); - $legacyDispatcher = OC::$server->getEventDispatcher(); - - $this->cardDavBackend = new CardDavBackend( - $db, - $principalBackend, - $userManager, - OC::$server->getGroupManager(), - $dispatcher, - $legacyDispatcher, - true - ); - } - - /** - * Copy a file. - * - * @param string $path - * @param string $newpath - * - * @return bool - */ - final public function copy($path, $newpath) - { - // FIXME: Implementation - return false; - } - - /** - * Create an address book. - * - * @param string $addressBookName address book name - * @param Config $config - * - * @return array|false - * - * @throws BadRequest - */ - final public function createDirectory($addressBookName, Config $config) - { - $addressBookId = $this->cardDavBackend->createAddressBook($this->principalUri, $addressBookName, array()); - if ($addressBookId !== null) { - return ['path' => $addressBookName, 'type' => 'dir']; - } - return false; - } - - /** - * Delete a card. - * - * @param string $path - * - * @return bool - */ - final public function delete($path) - { - list($addressBook, $filename) = $this->splitPath($path); - $addressBookId = $this->getAddressBookId($addressBook); - $this->cardDavBackend->deleteCard($addressBookId, $filename); - return true; - } - - /** - * Delete an addressBook. - * - * @param string $addressBook - * - * @return bool - */ - final public function deleteDirectory($addressBook) - { - $addressBookId = $this->getAddressBookId($addressBook); - if (!$addressBookId) { - return false; - } - - $this->cardDavBackend->deleteAddressBook($addressBookId); - return true; - } - - private function getAddressBookId($path) { - $path = explode('/', $path); - if (count($path) === 1) { - $addressBook = $this->cardDavBackend->getAddressBooksByUri($this->principalUri, $path[0]); - if ($addressBook) { - return $addressBook['id']; - } - } - - return null; - } - - /** - * Get all the meta data of a file or directory. - * - * @param string $path - * - * @return array|false - */ - final public function getMetadata($path) - { - $addressBookId = $this->getAddressBookId($path); - if ($addressBookId !== null) { - $addressBook = $this->cardDavBackend->getAddressBookById($addressBookId); - return $this->normalizeAddressBook($addressBook); - } else { - list($addressBook, $filename) = $this->splitPath($path); - $addressBookId = $this->getAddressBookId($addressBook); - $card = $this->cardDavBackend->getCard($addressBookId, $filename); - return $this->normalizeCard($card, $addressBook); - } - } - - /** - * Get the mimetype of a file. - * - * @param string $path - * - * @return array|false - */ - final public function mimeType($path) - { - return $this->getMetadata($path); - } - - /** - * Get the size of a file. - * - * @param string $path - * - * @return array|false - */ - final public function fileSize($path) - { - return $this->getMetadata($path); - } - - /** - * Get the timestamp of a file. - * - * @param string $path - * - * @return array|false - */ - final public function lastModified($path) - { - return $this->getMetadata($path); - } - - /** - * Get the visibility of a file. - * - * @param string $path - * - * @return array|false - */ - final public function visibility($path) - { - return $this->getMetadata($path); - } - - /** - * Check whether a file exists. - * - * @param string $path - * - * @return bool - */ - final public function fileExists($path) - { - if ($path === '.acl' && $this->defaultAcl) { - return true; - } - - $addressBookId = $this->getAddressBookId($path); - if ($addressBookId !== null) { - return true; - } else { - list($addressBook, $filename) = $this->splitPath($path); - $addressBookId = $this->getAddressBookId($addressBook); - $card = $this->cardDavBackend->getCard($addressBookId, $filename); - - return is_array($card); - } - } - - /** - * Check whether a directory exists. - * - * @param string $path - * - * @return bool - */ - final public function directoryExists($path) - { - return $this->fileExists($path); - } - - /** - * List contents of a directory. - * - * @param string $directory - * @param bool $recursive - * - * @return array - */ - final public function listContents($directory = '', $recursive = false) - { - if ($directory === '') { - $addressBooks = $this->cardDavBackend->getAddressBooksForUser($this->userId); - - return array_map(function ($addressBook) { - return $this->normalizeAddressBook($addressBook); - }, $addressBooks); - } else { - $directory = basename($directory); - - $addressBook = $this->cardDavBackend->getAddressBooksByUri($this->principalUri, $directory); - $cards = $this->cardDavBackend->getCards($addressBook['id']); - - $contents = []; - foreach ($cards as $card) { - $contents[] = $this->cardDavBackend->getCard($addressBook['id'], $card['uri']); - } - - return array_map(function($card) use ($directory) { - return $this->normalizeCard($card, $directory); - }, $contents); - } - } - - /** - * Read a file. - * - * @param string $path - * - * @return array|false - */ - final public function read($path) - { - if ($path === '.acl' && $this->defaultAcl) { - return $this->normalizeAcl($this->defaultAcl); - } - - list($addressBook, $filename) = $this->splitPath($path); - $addressBookId = $this->getAddressBookId($addressBook); - $card = $this->cardDavBackend->getCard($addressBookId, $filename); - - return $this->normalizeCard($card, $addressBook); - } - - /** - * Rename a file. - * - * @param string $path - * @param string $newpath - * - * @return bool - */ - final public function move($path, $newpath) - { - return false; - } - - /** - * Set the visibility for a file. - * - * @param string $path - * @param string $visibility - * - * @return array|false file meta data - */ - final public function setVisibility($path, $visibility) - { - return false; - } - - /** - * Write a new file. - * - * @param string $path - * @param string $contents - * @param Config $config Config object - * - * @return array|false false on failure file meta data on success - * - * @throws BadRequest - */ - final public function write($path, $contents, Config $config) - { - list($addressBook, $filename) = $this->splitPath($path); - $addressBookId = $this->getAddressBookId($addressBook); - if ($this->has($path)) { - $this->cardDavBackend->updateCard($addressBookId, $filename, $contents); - } else { - $this->cardDavBackend->createCard($addressBookId, $filename, $contents); - } - return true; - } - - private function normalizeAcl($acl) { - return [ - 'basename' => '.acl', - 'contents' => $acl, - 'mimetype' => 'text/turtle', - 'path' => '.acl', - 'size' => strlen($acl), - 'timestamp' => 0, - 'type' => 'file', - 'visibility' => 'public', - ]; - } - - private function normalizeCard($card, $basePath) { - if ( ! is_array($card)) { - return false; - } - - return [ - 'basename' => $card['uri'], - 'contents' => $card['carddata'], - 'mimetype' => 'text/vcard', - 'path' => $basePath . '/' . $card['uri'], - 'size' => $card['size'], - 'timestamp' => $card['lastmodified'], - 'type' => 'file', - 'visibility' => 'public', - ]; - } - - private function normalizeAddressBook($addressBook) - { - return [ - 'basename' => basename($addressBook['uri']), - 'mimetype' => 'directory', - 'path' => $addressBook['uri'], - 'size' => 0, - 'timestamp' => 0, - 'type' => 'dir', - // @FIXME: Use $node->getPermissions() to set private or public - // as soon as we figure out what Nextcloud permissions mean in this context - 'visibility' => 'public', - /*/ - 'CreationTime' => $node->getCreationTime(), - 'Etag' => $node->getEtag(), - 'Owner' => $node->getOwner(), - /*/ - ]; - } - - /** - * @param string $path - * - * @return string[] - */ - private function splitPath(string $path) - { - return [ - dirname($path), - basename($path) - ]; - } -} From 3440f8aeaf6a7930fc7bdee1e5fcb550fee60e77 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 17:10:35 +0200 Subject: [PATCH 10/16] remove return value --- src/NextcloudProfile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index 1c9cfe6..8b58901 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -42,7 +42,7 @@ final public function __construct($userId, $profile, $defaultAcl, $config) final public function copy(string $path, string $newpath, Config $config): void { // FIXME: Implementation - return false; + return; } /** From 362fb38d4ac5426b4c37366baf78b41e8516296d Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 17:26:25 +0200 Subject: [PATCH 11/16] align methods --- src/Nextcloud.php | 3 ++- src/NextcloudCalendar.php | 14 ++++++++++---- src/NextcloudContacts.php | 14 ++++++++++---- src/NextcloudProfile.php | 6 ++---- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/Nextcloud.php b/src/Nextcloud.php index 9fbe84b..af4b66c 100644 --- a/src/Nextcloud.php +++ b/src/Nextcloud.php @@ -274,12 +274,13 @@ final public function readStream(string $path) * * @param string $path * @param string $newpath + * @param Config $config * * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotPermittedException * @throws \OCP\Lock\LockedException */ - final public function move(string $path, string $newpath): void + final public function move(string $path, string $newpath, Config $config): void { try { $this->folder->get($path)->move($newpath); diff --git a/src/NextcloudCalendar.php b/src/NextcloudCalendar.php index c53bfe2..8dcfc96 100644 --- a/src/NextcloudCalendar.php +++ b/src/NextcloudCalendar.php @@ -2,7 +2,6 @@ namespace Pdsinterop\Flysystem\Adapter; -use League\Flysystem\Adapter\Polyfill\StreamedTrait; use League\Flysystem\AdapterInterface; use League\Flysystem\Config; @@ -19,8 +18,6 @@ */ class NextcloudCalendar implements AdapterInterface { - use StreamedTrait; - /** @var CalDavBackend */ private $calDavBackend; /** @var string */ @@ -292,8 +289,9 @@ final public function read(string $path): string * * @param string $path * @param string $newpath + * @param Config $config */ - final public function move(string $path, string $newpath): void + final public function move(string $path, string $newpath, Config $config): void { return; } @@ -329,6 +327,14 @@ final public function write(string $path, string $contents, Config $config): voi } } + final public function writeStream(string $path, $contents, Config $config): void + { + } + + final public function readStream(string $path): void + { + } + private function normalizeAcl($acl) { return [ 'basename' => '.acl', diff --git a/src/NextcloudContacts.php b/src/NextcloudContacts.php index 56d6737..a23ac75 100644 --- a/src/NextcloudContacts.php +++ b/src/NextcloudContacts.php @@ -2,7 +2,6 @@ namespace Pdsinterop\Flysystem\Adapter; -use League\Flysystem\Adapter\Polyfill\StreamedTrait; use League\Flysystem\FilesystemAdapter; use League\Flysystem\FileAttributes; use League\Flysystem\Config; @@ -19,8 +18,6 @@ */ class NextcloudContacts implements FilesystemAdapter { - use StreamedTrait; - /** @var CardDavBackend */ private $cardDavBackend; /** @var string */ @@ -298,8 +295,9 @@ final public function read(string $path): string * * @param string $path * @param string $newpath + * @param Config $config */ - final public function move(string $path, string $newpath): void + final public function move(string $path, string $newpath, Config $config): void { return; } @@ -340,6 +338,14 @@ final public function write(string $path, string $contents, Config $config): voi return; } + final public function writeStream(string $path, $contents, Config $config): void + { + } + + final public function readStream(string $path): void + { + } + private function normalizeAcl($acl) { return [ 'basename' => '.acl', diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index 8b58901..b92ea96 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -2,7 +2,6 @@ namespace Pdsinterop\Flysystem\Adapter; -use League\Flysystem\Adapter\Polyfill\StreamedTrait; use League\Flysystem\FilesystemAdapter; use League\Flysystem\FileAttributes; use League\Flysystem\Config; @@ -13,8 +12,6 @@ */ class NextcloudProfile implements FilesystemAdapter { - use StreamedTrait; - /** @var ServerConfig */ private $config; /** @var string */ @@ -213,8 +210,9 @@ final public function read(string $path): string * * @param string $path * @param string $newpath + * @param Config $config */ - final public function move(string $path, string $newpath): void + final public function move(string $path, string $newpath, Config $config): void { return; } From 91c626c7cb4cd6ee5156d4712bc4bbfb3f466070 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Wed, 30 Sep 2026 17:49:56 +0200 Subject: [PATCH 12/16] add missing functions as dummies --- src/NextcloudProfile.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index b92ea96..94318a2 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -242,6 +242,15 @@ final public function write(string $path, string $contents, Config $config): voi } } + + final public function writeStream(string $path, $contents, Config $config): void + { + } + + final public function readStream(string $path): void + { + } + private function normalizeAcl($acl) { return [ 'basename' => '.acl', From accd030d33a5af8e69e389842ea2978a16bd0a39 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Thu, 1 Oct 2026 15:38:51 +0200 Subject: [PATCH 13/16] also allow /card --- src/NextcloudProfile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index 94318a2..ba14ab5 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -154,7 +154,7 @@ final public function fileExists(string $path): bool return true; } - if ($path === 'card') { + if ($path === 'card' || $path === '/card') { return true; } return false; From a6ccefeda0031d84b8f7da5afc8f5dbfc0425a4e Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Mon, 5 Oct 2026 11:23:44 +0200 Subject: [PATCH 14/16] remove try/catch --- src/Nextcloud.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Nextcloud.php b/src/Nextcloud.php index af4b66c..8f8e669 100644 --- a/src/Nextcloud.php +++ b/src/Nextcloud.php @@ -102,19 +102,15 @@ final public function deleteDirectory(string $dirname): void */ final public function getAttributes(string $path): FileAttributes { - try { - $node = $this->folder->get($path); - $metaData = $this->normalizeNodeInfo($node); - return new FileAttributes( - $path, - $metaData['size'], - $metaData['visibility'], - $metaData['timestamp'], - $metaData['mimetype'] - ); - } catch (\OCP\Files\NotFoundException $exception) { - return false; - } + $node = $this->folder->get($path); + $metaData = $this->normalizeNodeInfo($node); + return new FileAttributes( + $path, + $metaData['size'], + $metaData['visibility'], + $metaData['timestamp'], + $metaData['mimetype'] + ); } /** From 9019f756170e50bc9f265a805ce26d289d752e35 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Tue, 6 Oct 2026 11:07:27 +0200 Subject: [PATCH 15/16] add EOL time --- .github/workflows/php.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index fbf453d..3af6d67 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -75,7 +75,7 @@ jobs: matrix: php: - '8.3' # from 2023-11 to 2025-12 (2027-12) - - '8.4' + - '8.4' # from 2024-11 to 2026-12 (2028-12) steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 @@ -117,7 +117,7 @@ jobs: matrix: php: - '8.3' # from 2023-11 to 2025-12 (2027-12) - - '8.4' + - '8.4' # from 2024-11 to 2026-12 (2028-12) steps: - uses: actions/checkout@v4 - uses: docker://pipelinecomponents/php-codesniffer From 6849a7e6358da1a10acd853cf0320a02998880ce Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Tue, 6 Oct 2026 11:10:17 +0200 Subject: [PATCH 16/16] also for .acl --- src/NextcloudProfile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NextcloudProfile.php b/src/NextcloudProfile.php index ba14ab5..4fb7c55 100644 --- a/src/NextcloudProfile.php +++ b/src/NextcloudProfile.php @@ -150,7 +150,7 @@ final public function visibility(string $path): FileAttributes */ final public function fileExists(string $path): bool { - if ($path === '.acl' && $this->defaultAcl) { + if (($path === '.acl' || $path === '/.acl') && $this->defaultAcl) { return true; }