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

Local adapter private directory visibility #1762

Open
olegkhuss opened this issue Mar 8, 2024 · 5 comments
Open

Local adapter private directory visibility #1762

olegkhuss opened this issue Mar 8, 2024 · 5 comments

Comments

@olegkhuss
Copy link

Hi guys, can you confirm this is really a bug, I created a test to reproduce it and a possible fix

Bug Report

Q A
Flysystem Version 3.x
Adapter Name src/Local/LocalFilesystemAdapter.php
Adapter version 3.x

Summary

When I create a directory with ['visibility' => 'private'] config and retrieve visibility it returns me "public" but I expect it to be "private"

How to reproduce

git clone git@github.com:olegkhuss/flysystem.git .
composer install
vendor/bin/phpunit --filter="test_private_directory_visibility" src/Local/LocalFilesystemAdapterTest.php

The test above will fail, but I expect it to pass,

The test below will pass

git checkout fix/local_adapter_private_visibility
vendor/bin/phpunit --filter="test_private_directory_visibility" src/Local/LocalFilesystemAdapterTest.php
@frankdejonge
Copy link
Member

Hi, @olegkhuss this is intended behaviour. The directory permissions are write-mostly, as in, they have a second priority to the other methods. It can be part of a directory listing, but is not required. The visibility method is intended to be used for files, which is why you're getting an unexpected result. In practice, for file storage needs, directories are not super important. It's when people use Flysystem as an API for specific local filesystem operations that this is ...problematic.

@olegkhuss
Copy link
Author

olegkhuss commented Mar 8, 2024 via email

@frankdejonge
Copy link
Member

@olegkhuss for clarity, V3 optimised a lot of paths to reduce the amount of expensive calls while retaining (almost) all functionality. It's better for the performance of your app and better for the environmental impact of running software to do less. This is why it changed.

@olegkhuss
Copy link
Author

olegkhuss commented Mar 8, 2024 via email

@olegkhuss
Copy link
Author

It seems to me a bug still, the permissions in the filesystem are set correctly
but the code below doesn't return me the right value

$adapter = new LocalFilesystemAdapter(static::ROOT);

$adapter->createDirectory('public_directory', new Config(['visibility' => 'public']));
$publicVisibility = $adapter->visibility('public_directory');

$adapter->createDirectory('private_directory', new Config(['visibility' => 'private']));
$privateVisibility = $adapter->visibility('private_directory'); 

$this->assertEquals('public', $publicVisibility->visibility()); // okay
$this->assertEquals('private', $privateVisibility->visibility());  // ! failed, expect "private" but actual is "public"   

Now see the picture below, it returns me "public" in both cases whereas actual permissions are different?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants