From f93c94b16f30a5a5ece0953e39429859d3ec0a29 Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Mon, 7 Oct 2024 15:01:03 +0200 Subject: [PATCH 1/4] feat: update according to flysystem upgrade --- model/DataStore/PersistDataService.php | 21 +++++++-------------- model/DeliveryArchiveService.php | 10 +++++----- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/model/DataStore/PersistDataService.php b/model/DataStore/PersistDataService.php index d8067fc8..8919033c 100644 --- a/model/DataStore/PersistDataService.php +++ b/model/DataStore/PersistDataService.php @@ -90,13 +90,13 @@ private function removeArchive(string $resourceId, string $fileSystemId, string // There is a bug for gcp storage adapter - when deleting a dir with only one file exception is thrown // This is why the file itself is removed first $zipFileName = $this->getZipFileName($resourceId, $tenantId); - if ($this->getDataStoreFilesystem($fileSystemId)->has($zipFileName)) { + if ($this->getDataStoreFilesystem($fileSystemId)->fileExists($zipFileName)) { $this->getDataStoreFilesystem($fileSystemId)->delete($zipFileName); } $directoryPath = $this->getZipFileDirectory($resourceId, $tenantId); - if ($this->getDataStoreFilesystem($fileSystemId)->has($directoryPath)) { - $this->getDataStoreFilesystem($fileSystemId)->deleteDir($directoryPath); + if ($this->getDataStoreFilesystem($fileSystemId)->directoryExists($directoryPath)) { + $this->getDataStoreFilesystem($fileSystemId)->deleteDirectory($directoryPath); } } @@ -150,17 +150,10 @@ private function moveExportedZipTest( $contents = file_get_contents($zipFile); - if ($this->getDataStoreFilesystem($fileSystemId)->has($zipFileName)) { - $this->getDataStoreFilesystem($fileSystemId)->update( - $zipFileName, - $contents - ); - } else { - $this->getDataStoreFilesystem($fileSystemId)->write( - $zipFileName, - $contents - ); - } + $this->getDataStoreFilesystem($fileSystemId)->write( + $zipFileName, + $contents + ); } } } diff --git a/model/DeliveryArchiveService.php b/model/DeliveryArchiveService.php index b66f4698..1c6ee113 100644 --- a/model/DeliveryArchiveService.php +++ b/model/DeliveryArchiveService.php @@ -84,7 +84,7 @@ public function archive($compiledDelivery, $force = false) { $fileName = $this->getArchiveFileName($compiledDelivery); - if (!$force && $this->getArchiveFileSystem()->has($fileName)) { + if (!$force && $this->getArchiveFileSystem()->fileExists($fileName)) { throw new DeliverArchiveExistingException( 'Delivery archive already created: ' . $compiledDelivery->getUri() ); @@ -135,7 +135,7 @@ public function unArchive($compiledDelivery, $force = false) { $fileName = $this->getArchiveFileName($compiledDelivery); - if (!$this->getArchiveFileSystem()->has($fileName)) { + if (!$this->getArchiveFileSystem()->fileExists($fileName)) { throw new DeliveryArchiveNotExistingException( 'Delivery archive not exist please generate: ' . $compiledDelivery->getUri() ); @@ -172,7 +172,7 @@ public function unArchive($compiledDelivery, $force = false) public function deleteArchive($compiledDelivery) { $fileName = $this->getArchiveFileName($compiledDelivery); - if ($this->getArchiveFileSystem()->has($fileName)) { + if ($this->getArchiveFileSystem()->fileExists($fileName)) { $this->getArchiveFileSystem()->delete($fileName); } @@ -207,7 +207,7 @@ private function copyFromZip($zip) $entryName = implode('/', $parts); $stream = $zip->getStream($zipEntryName); if (is_resource($stream)) { - $fileSystem->getFileSystem($bucketDestination)->putStream($entryName, $stream); + $fileSystem->getFileSystem($bucketDestination)->writeStream($entryName, $stream); } } } @@ -229,7 +229,7 @@ private function uploadZip($compiledDelivery) if (!file_exists($zipPath) || ($stream = fopen($zipPath, 'r')) === false) { throw new DeliveryZipException('Cannot open local tmp zip archive'); } - $this->getArchiveFileSystem()->putStream($fileName, $stream); + $this->getArchiveFileSystem()->writeStream($fileName, $stream); fclose($stream); return $fileName; From 293cd0bf9ceb9ec8625f1e61b5d5dbc641a430d4 Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Wed, 16 Oct 2024 11:09:02 +0200 Subject: [PATCH 2/4] chore: update ci php version runs --- .github/workflows/continuous-integration.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 7829b6f1..21e22795 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -14,9 +14,9 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-latest ] - php-version: [ '7.4', '8.0', '8.1' ] + php-version: [ '8.1', '8.2', '8.3' ] include: - - php-version: '8.1' + - php-version: '8.3' coverage: true steps: From 850722560f65069a64d07a4f9fce2dcece7768a5 Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Wed, 23 Oct 2024 22:11:41 +0200 Subject: [PATCH 3/4] chore: depend on generis implementation --- model/DataStore/PersistDataService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/DataStore/PersistDataService.php b/model/DataStore/PersistDataService.php index 8919033c..0722316b 100644 --- a/model/DataStore/PersistDataService.php +++ b/model/DataStore/PersistDataService.php @@ -25,7 +25,7 @@ use common_Exception; use common_exception_Error; use common_exception_NotFound; -use oat\oatbox\filesystem\FileSystem; +use oat\oatbox\filesystem\FilesystemInterface; use oat\oatbox\filesystem\FileSystemService; use oat\oatbox\service\ConfigurableService; use oat\tao\helpers\FileHelperService; @@ -71,7 +71,7 @@ public function remove(ResourceSyncDTO $resourceSyncDTO): void * @throws common_exception_Error * @throws common_exception_NotFound */ - private function getDataStoreFilesystem(string $fileSystemId): FileSystem + private function getDataStoreFilesystem(string $fileSystemId): FilesystemInterface { return $this->getFileSystemManager()->getFileSystem($fileSystemId); } From 2b19073462904e435b2bae23ccbe6006b2e5b8ae Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Thu, 28 Nov 2024 10:16:13 +0100 Subject: [PATCH 4/4] chore: update generis and tao-core dependency --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 39c270fa..8cd55f29 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ "minimum-stability": "dev", "require": { "oat-sa/oatbox-extension-installer": "~1.1||dev-master", - "oat-sa/generis": ">=15.36.4", - "oat-sa/tao-core": ">=54.14.7", + "oat-sa/generis": ">=16.0.0", + "oat-sa/tao-core": ">=54.26.0", "oat-sa/extension-tao-delivery": ">=15.0.0", "oat-sa/extension-tao-group": ">=7.0.0", "oat-sa/extension-tao-item": ">=11.0.0",