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

ext-eio readlink not (always?) returning #76

Open
gizahNL opened this issue Jan 23, 2020 · 4 comments
Open

ext-eio readlink not (always?) returning #76

gizahNL opened this issue Jan 23, 2020 · 4 comments

Comments

@gizahNL
Copy link

gizahNL commented Jan 23, 2020

I've noticed that ls does not list (all?) my symlinks in a certain dir when using eio adapter.

It seems to be due to eio_readlink in the cases of these files returning only the pointed file as a result (instead of a full path), as the files are relatively linked

@clue
Copy link
Member

clue commented Jan 26, 2020

@gizahNL Thanks for reporting! Can you provide a simple test script to reproduce the problem you're seeing?

@gizahNL
Copy link
Author

gizahNL commented Jan 27, 2020

run this in dir to create links:

#!/bin/bash

WRKDIR=$(pwd)
TESTDIR="$WRKDIR/testlink"
if [[ -d "$TESTDIR" ]]
then 
    exit 0
fi
TARGET="target_link"
RELATIVE="link_relative"
FULLPATH="link_fullpath"

mkdir "$TESTDIR"
cd "$TESTDIR"
touch "$TARGET"
ln -s  "$TARGET" "$RELATIVE"
ln -s "$TESTDIR/$TARGET" "$FULLPATH"

then run from same dir:

<?php
require './vendor/autoload.php';
$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$dir = "./testlink/";
$filesystem->dir($dir)->ls()->then(function ($list) {
    foreach ($list as $file) {
        $filename = $file->getName();
	echo($filename."\n");
    }
}, function ($error) {
    echo($error->getMessage());
});

echo 'Using ', get_class($filesystem->getAdapter()), PHP_EOL;
$loop->run();

output with eio:

Using React\Filesystem\Eio\Adapter
target_link
link_fullpath

output with childprocess:

Using React\Filesystem\ChildProcess\Adapter
link_fullpath
link_relative
test_target

expected eio output:

Using React\Filesystem\Eio\Adapter
link_fullpath
link_relative
test_target

@gizahNL
Copy link
Author

gizahNL commented Jan 27, 2020

My guess for the simplest fix would most likely be to intercept the eio_readlink output, and depending if output starts with a forward slash prepend the path of the dir containing the file we are running readlink on so as to always pas a full path

@WyriHaximus
Copy link
Member

FYI ext-eio tends to have a will of it's own and doesn't always behave as we intend it to.

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

3 participants