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

Request for a disconnect method #418

Open
ghost opened this issue Jun 6, 2016 · 0 comments
Open

Request for a disconnect method #418

ghost opened this issue Jun 6, 2016 · 0 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jun 6, 2016

Hi,

Time to time this line causes error below. I had to remove suppression and catch it with error_get_last function otherwise it throws this exception.

{"type":2,"message":"ftp_chdir(): Timeout.","file":"/vendor/knplabs/gaufrette/src/Gaufrette/Adapter/Ftp.php","line":348}

When it happens I have to explicitly set connection variable to null by calling the temporary method below and try FTPing my file again which solves the problem.

public function disconnect()
{
    $this->connection = null;
}

Suggestion:
We need a way of manually disconnecting from the open/currently used adapter so that when we catch this exception we can assume that it was a timeout issue or something else then try to FTPing our file one more time before giving up. Temporary solution below solves my problem but I have to fork and modify the library for such a small fix.

while ($i < 2) {
    try {
        $this->adapter->write($path, $fileContent);

        return;
    } catch (RuntimeException $e) {
        $this->adapter->disconnect();
    }

    ++$i;
}

throw new AnotherException('Error message');

Thanks

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