Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update flysystem usage after upgrade #4115

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion actions/class.RdfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ public function editInstance()
* Duplicate the current instance
* render a JSON response
*
* @throws \League\Flysystem\FileExistsException
* @throws common_Exception
* @throws common_exception_BadRequest
* @throws common_exception_Error
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"oat-sa/jig": "~0.2",
"oat-sa/composer-npm-bridge": "~0.4.2||dev-master",
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.36.4",
"oat-sa/generis": "dev-feat/REL-1723/update-flysystem-lib",
"composer/package-versions-deprecated": "^1.11",
"paragonie/random_compat": "^2.0",
"phpdocumentor/reflection-docblock": "^5.2",
Expand Down
2 changes: 0 additions & 2 deletions models/classes/GenerisServiceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public function bindProperties(core_kernel_classes_Resource $instance, $properti
* @param core_kernel_classes_Resource $instance
* @param core_kernel_classes_Class $clazz
* @return core_kernel_classes_Resource
* @throws \League\Flysystem\FileExistsException
* @throws \common_Exception
* @throws \common_exception_Error
*/
Expand Down Expand Up @@ -209,7 +208,6 @@ public function cloneInstance(core_kernel_classes_Resource $instance, core_kerne
* @param core_kernel_classes_Resource $source
* @param core_kernel_classes_Resource $destination
* @param core_kernel_classes_Property $property
* @throws \League\Flysystem\FileExistsException
* @throws \common_Exception
* @throws \common_exception_Error
*/
Expand Down
2 changes: 1 addition & 1 deletion models/classes/service/class.FileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function deleteDirectoryById($id)
->getServiceLocator()
->get(FileSystemService::SERVICE_ID)
->getFileSystem($this->getFsId($public))
->deleteDir($path);
->deleteDirectory($path);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions models/classes/service/class.StorageDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*
*/

use League\Flysystem\Local\LocalFilesystemAdapter;
use oat\tao\model\websource\Websource;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use oat\oatbox\filesystem\Directory;
use Psr\Http\Message\StreamInterface;

Expand Down Expand Up @@ -113,7 +113,7 @@ public function getRelativePath()
public function getPath()
{
$adapter = $this->getFileSystem()->getAdapter();
if (!$adapter instanceof Local) {
if (!$adapter instanceof LocalFilesystemAdapter) {
throw new common_exception_InconsistentData(__CLASS__ . ' can only handle local files');
}
return $adapter->getPathPrefix() . $this->getPrefix();
Expand Down
3 changes: 1 addition & 2 deletions models/classes/state/StateMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public function removeState($userId, $callId)

public function removeBackup($userId, $callId)
{

return $this->getFileSystem()->delete($this->generateSerial($userId, $callId));
$this->getFileSystem()->delete($this->generateSerial($userId, $callId));
}

private function generateSerial($userId, $callId)
Expand Down
1 change: 0 additions & 1 deletion models/classes/taskQueue/Task/FilesystemAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ protected function saveStreamToStorage($stream, $fileName)
* @param string $fileName
* @return string
*
* @throws \League\Flysystem\FileExistsException
* @throws \common_Exception
*/
protected function saveStringToStorage($string, $fileName)
Expand Down
9 changes: 5 additions & 4 deletions models/classes/websource/BaseWebsource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace oat\tao\model\websource;

use GuzzleHttp\Psr7\Stream;
use League\Flysystem\FileNotFoundException;
use League\Flysystem\FilesystemException;
use oat\oatbox\Configurable;
use oat\oatbox\filesystem\FileSystemService;
use oat\oatbox\service\ServiceManager;
Expand Down Expand Up @@ -107,10 +107,10 @@ public function getFileStream($filePath)
$fs = $this->getFileSystem();
try {
$resource = $fs->readStream($filePath);
} catch (FileNotFoundException $e) {
} catch (FilesystemException $e) {
throw new \tao_models_classes_FileNotFoundException($filePath);
}
return new Stream($resource, ['size' => $fs->getSize($filePath)]);
return new Stream($resource, ['size' => $fs->fileSize($filePath)]);
}

/**
Expand All @@ -119,10 +119,11 @@ public function getFileStream($filePath)
* @return string|false The file mime-type or false on failure.
* @throws \common_exception_Error
* @throws \common_exception_NotFound
* @throws FilesystemException
*/
public function getMimetype($filePath)
{
$mimeType = $this->getFileSystem()->getMimetype($filePath);
$mimeType = $this->getFileSystem()->mimeType($filePath);

$pathParts = pathinfo($filePath);
if (isset($pathParts['extension'])) {
Expand Down
1 change: 0 additions & 1 deletion scripts/install/SetServiceFileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use oat\oatbox\filesystem\FileSystemService;
use oat\tao\model\websource\TokenWebSourceService;
use tao_models_classes_service_FileStorage;
use League\Flysystem\Adapter\Local;
use oat\tao\model\websource\FlyTokenWebSource;

/**
Expand Down
6 changes: 3 additions & 3 deletions test/TaoPhpUnitTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace oat\tao\test;

use League\Flysystem\Memory\MemoryAdapter;
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
use oat\generis\persistence\PersistenceManager;
use oat\generis\test\GenerisPhpUnitTestRunner;
use oat\oatbox\filesystem\Directory;
Expand Down Expand Up @@ -154,9 +154,9 @@ protected function getTempDirectory()

$adapters = $fileSystemService->getOption(FileSystemService::OPTION_ADAPTERS);
$tmpDir = \tao_helpers_File::createTempDir();
if (class_exists('League\Flysystem\Memory\MemoryAdapter')) {
if (class_exists('League\Flysystem\InMemory\InMemoryFilesystemAdapter')) {
$adapters[$this->tempFileSystemId] = [
'class' => MemoryAdapter::class
'class' => InMemoryFilesystemAdapter::class
];
} else {
$adapters[$this->tempFileSystemId] = [
Expand Down
2 changes: 1 addition & 1 deletion test/unit/models/classes/websource/BaseWebsourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private function getFileSystemMockWithMimeType($mimeType)
->getMock();

$fileSystemMock
->method('getMimetype')
->method('mimeType')
->willReturn($mimeType);

return $fileSystemMock;
Expand Down
Loading