filesystem icon indicating copy to clipboard operation
filesystem copied to clipboard

ext-eio readlink not (always?) returning

Open gizahNL opened this issue 5 years ago • 4 comments

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

gizahNL avatar Jan 23 '20 16:01 gizahNL

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

clue avatar Jan 26 '20 12:01 clue

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 avatar Jan 27 '20 08:01 gizahNL

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

gizahNL avatar Jan 27 '20 09:01 gizahNL

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

WyriHaximus avatar Feb 02 '20 21:02 WyriHaximus