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

Synology ftp #305

Closed
kristianedlund opened this issue Nov 1, 2014 · 5 comments
Closed

Synology ftp #305

kristianedlund opened this issue Nov 1, 2014 · 5 comments

Comments

@kristianedlund
Copy link

Hi
I was testing flysystem with the FTP on a synology NAS. It turns out the response to the STAT command is a tad different than the default implementation when a file does not exist.

Instead of just returning two lines like standard ftp servers, it returns:

211- status of test.txt:
ftpd: test.txt: No such file or directory.
211 End of status

I am not sure how to approach this, or if it should be handled by flysystem. So far I hacked it by just changing the ftp function getMetadata to

public function getMetadata($path)
{
    if (empty($path) ||  ! ($object = ftp_raw($this->getConnection(), 'STAT ' . $path)) || count($object) < 3) {
        return false;
    }

    if(substr( $object[1], 0, 5 ) === "ftpd:") {
        return false;
    }

    return $this->normalizeObject($object[1], '');
}

I will be happy to make a pull request, but I am uncertain how to approach it the problem.

@kristianedlund
Copy link
Author

Just as a note. the function in ftp.php listDirectoryContents also needs to be changed.

protected function listDirectoryContents($directory, $recursive = true)
{
    $listing = ftp_rawlist($this->getConnection(), '-lna ' . $directory, $recursive);

    if ($listing === false) {
        return array();
    }

    if (substr($listing[0], 0, 5) === "ftpd:") {
        return array();
    }

    return $this->normalizeListing($listing, $directory);
}

@frankdejonge
Copy link
Member

@kristianedlund Hi, I'm not familiar with synology NAS. I'm assuming this is a windows ftp server, correct?

@kristianedlund
Copy link
Author

@FrenkyNet No the NAS is running on a unix system and most of the answers comes out as correct unix answers. Such as the stat command when the file is found. However, it has an extra line when the file is not found.

I have a local copy working with the synology server, and I am just working towards making it a unit tested version before submitting a pull request for it.

@frankdejonge
Copy link
Member

@kristianedlund awesome, looking forward to the PR! Would maybe even make sense to extend the Ftp adapter rather than handling different cases in one.

@kristianedlund
Copy link
Author

@FrenkyNet That is up to you. I can do either one I think.
From a user perspective I can see both pros and cons.
The pro is that you get leaner code for you specific ftp
The con is that you have to know which FTP server you are connecting to.

But from the whole issue I can see around windows based I think you might end up with a whole lot of FTP adapters. On the other hand it is not a bigger issue than it can be refactored later on.

Just let me know which one you prefer and I will aim for that.

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