Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

RecursiveDirectoryFtpIterator #4354

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

Closed
wants to merge 9 commits into from
Closed

RecursiveDirectoryFtpIterator #4354

wants to merge 9 commits into from

Conversation

gajdaw
Copy link
Contributor

@gajdaw gajdaw commented May 21, 2012

Bug fix: yes
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: Build Status
Fixes the following tickets: #3585
Todo: This is only the first step to get some feedback
License of the code: MIT

@travisbot
Copy link

This pull request passes (merged db12c2c into 1407f11).

{
if ($this->isDir()) {
return $this->getPath();
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use else as the if returns

@vicb
Copy link
Contributor

vicb commented May 21, 2012

How does this PR relate to #4335 ?

@travisbot
Copy link

This pull request passes (merged e047e573 into 1407f11).

@gajdaw
Copy link
Contributor Author

gajdaw commented May 21, 2012

@vicb 4335 is a solution to a general problem with filters. I think that in their current state they can not be used to filter user created iterators.

Probably inside filter's accept method we should call current().

Inside ExcludeDirectoryFilterIterator we have:

$path = $this->isDir() ? $this->getSubPathname() : $this->getSubPath();

The filter is ExcludeDirectoryFilterIterator.

The item is Symfony\Component\Finder\SplFileInfo.

The filter filters iterator Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator (created in Finder::searchInDirectory()).

Methods:

$this->isDir()
$this->getSubPathname()
$this->getSubPath();

are called from RecursiveDirectoryIterator passed to filters.

Not from our own item Symfony\Component\Finder\SplFileInfo.

The solution is to add:

$this->current()->isDir()

I think it is a general, not necessarily ftp-related, problem.

I found it indispensable during my work on RecursiveDirectoryFtpIterator.

@vicb
Copy link
Contributor

vicb commented May 21, 2012

@vicb 4335 is a solution to a general problem with filters. I think that in their current state they can not be used to filter user created iterators.

Could this be solved by using a DirectoryIterator type hint in the constructor of would it be too restrictive ?

@gajdaw
Copy link
Contributor Author

gajdaw commented May 21, 2012

In case of ExcludeDirectoryFilterIterator we depend on:

$this->getSubPathname()
$this->getSubPath();

Thus maybe constructor's parameter should be RecursiveDirectoryIterator?

I thought about it. But it breaks tests: there are 42 errors. I wasn't sure about it and left it as it is.

\RecursiveIteratorIterator::SELF_FIRST
);
if (Iterator\RecursiveDirectoryFtpIterator::isValidFtpUrl($dir)) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra empty line to be removed

@vicb
Copy link
Contributor

vicb commented May 21, 2012

Is is intended that all methods of FtpSplfileInfo and RecursiveDirectoryFtpIterator are public ?

@travisbot
Copy link

This pull request fails (merged a29d57b7 into 1407f11).

@gajdaw
Copy link
Contributor Author

gajdaw commented May 21, 2012

@vicb I don't know where to put Ftp class. It does not belong to Finder\Iterators. But this decision is for someone with greater experience. That's why I published this only half-started code of RecursiveDirectoryFtpIterator. Of course I can embed ftp code inside RecursiveDirectoryFtpIterator but it will be worse IMHO.

I think we need universal ftp class. Maybe as a new component?

Current state of implementation consists of three classes:

Ftp
RecursiveDirectoryFtpIterator
FtpSplFileInfo

I will use SplFileInfo which supports relative paths as a base class for FtpSplFileInfo, but currently it breaks some tests.

@stof
Copy link
Member

stof commented May 21, 2012

I don't think we need a new component for this Ftp class. It would be overkill IMO.
I would suggest creating a dedicated subnamespace in the Finder component (either Ftp or Util), containing the Ftp class (maybe renamed if the subnamespace itself is named Ftp) and the FtpSplFileInfo classes.

@gajdaw
Copy link
Contributor Author

gajdaw commented May 21, 2012

@stof Thanks for your suggestion. I will create Finder\Util subnamespace and Finder\Util\Ftp class.

@travisbot
Copy link

This pull request passes (merged 8e20e04 into ea33d4d).

@travisbot
Copy link

This pull request passes (merged 6d41c29 into ea33d4d).

@gajdaw
Copy link
Contributor Author

gajdaw commented May 22, 2012

@vicb You are right: I should use Finder\SplFileInfo as a base class instead \SplFileInfo.

Next change was to use as much of Finder\SplFileInfo as possible. I removed all my inventions :-)

@fabpot
Copy link
Member

fabpot commented May 22, 2012

I'm not we want to support FTP in the Finder. The ticket was about fixing the failure for non-rewindable streams (FTP being just an example).

@gajdaw
Copy link
Contributor Author

gajdaw commented May 22, 2012

@fabpot Sorry for this mess. My solution consists of ftp iterator and solves only the problems with ftp stream. If you consider it inadequate - sorry.

@gajdaw gajdaw closed this May 22, 2012
@gajdaw
Copy link
Contributor Author

gajdaw commented May 23, 2012

@fabpot What do you think about minimal ftp implementation (in Util\Ftp) + FtpRecursiveDirectoryIterator + FtpSplFileInfo?

@fabpot
Copy link
Member

fabpot commented May 23, 2012

Who is still using FTP nowadays? Note that this is not an ironical question but a real one. I stopped using FTP many many years ago, and I wonder if this is still a protocol widely used.

@gajdaw
Copy link
Contributor Author

gajdaw commented May 23, 2012

I agree with you. But how can we solve ->in('ftp://...') without ftp extension and without openning new ftp connection for each folder (or even each file)?

@mvrhov
Copy link

mvrhov commented May 23, 2012

I don't know who uses it inside their apps. But FTP is still pretty much the only option to upload the files if your website is on shared hosting.

@gajdaw
Copy link
Contributor Author

gajdaw commented May 23, 2012

@mvrhov Thats exactly the reason I've tried to correct ->in('ftp://'). In Symfony 1 I use my sfFtpPlugin to deploy a project
http://www.symfony-project.org/plugins/sfFtpPlugin

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

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.