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

Check Symlink #203

Closed
tomfischerNL opened this issue Jul 15, 2014 · 13 comments
Closed

Check Symlink #203

tomfischerNL opened this issue Jul 15, 2014 · 13 comments

Comments

@tomfischerNL
Copy link

Hi There,

Just made a quick fix to check whether the type is 'dir, file or link (symlink)'

In the file
\League\Flysystem\Adapter\AbstractFtpAdapter.php link 262 I added:

if ($type === 'dir') {
            return compact('type', 'path');
        }
        elseif($type === 'file')
        {
            if($permissions{0} === 'l')
            {
                $type = 'link';
            }
        }

Now you can check if there is a symbolic link so that the read() method doesn't get any errors. ;)

@thijskaspers
Copy link

I'm having this bug as well... A symbolic link directory is returned as "type = file" when I use the listContents method. Would be nice to retrieve it as "type = link" so I can do something else with it.

@frankdejonge
Copy link
Member

@wateengoedidee hi, the concept of links is not supported by a large number of adapters. Is there a way to check to what type the symlink links?

@tomfischerNL
Copy link
Author

Perhaps readlink? http://php.net/manual/en/function.readlink.php
Then check the readlink content. (file or dir)

But this is only necessary for the FTP adapter?

@frankdejonge
Copy link
Member

@wateengoedidee that function of only good for the local FS, not for ftp though. I'll do some research on this.

@tomfischerNL
Copy link
Author

;)

@thijskaspers
Copy link

@FrenkyNet Thanks for looking into this. We are using flysystem to retrieve files over FTP and back them up to S3. Looping over the listContents fails, since the name of a symlink is "name -> destination" and type = "file", which results in an "incorrect file".

@thijskaspers
Copy link

@FrenkyNet Did you find some time to look into this? I hope it's possible, thanks.

@frankdejonge
Copy link
Member

@24creative unfortunately I haven't yet. There's no PHP function to follow the link, which would be needed to check the type. I'm working at a client at the moment (freelance) so it's a bit tough to get time free to dive into this. If you come across anything remotely helpful I'll gladly read through it.

@frankdejonge
Copy link
Member

I haven't found a way to deal with this. Closing this due because we're unable to support this across all adapters. When a solution is found, a PR would be very welcome. I'll add notes about links not being supported for now.

@thijskaspers
Copy link

@FrenkyNet There's no PHP function to follow the link, but we don't need to know where the link leads to, we only need to know if it is a symlink so that we can ignore it or do other stuff with it. A link now shows as a regular file with the listContents method.

Isn't this possible? If not then it's a bummer. Thanks again for looking into this.

@frankdejonge
Copy link
Member

@24creative in the response the FTP function give, instead of the file or dir, you get link. No other type is specified. In other worlds there's no way you'd know how to handle this even when detecting it. I've also tried looking up ways to use the FTP command flags in order to follow links and such. The problem here lies more with the protocol even. Links seem to be bolted on the initial implementation and had to conform to an output standard which didn't allow for a more detailed response.

@frankdejonge
Copy link
Member

@24creative I would be open to a PR which just flat out ignores them though. That's the only thing you can reliably do.

@jonnott
Copy link

jonnott commented Jan 27, 2016

Really could do with a way to work around symlinks, for both Local and FTP adapters..

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

4 participants