Avoid creating local files for "matchless" patterns #1470

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@shashurup

When there is no match for a pattern fabric creates empty local file
with pattern name.

Georgy Kibardin Avoid creating local files for "matchless" patterns
When there is no match for a pattern fabric creates empty local file
with pattern name.
561230d
@mmalchuk

+1 this fix is really needed
also closes #935

@bitprophet bitprophet added this to the 1.10.4 milestone Jul 3, 2016
@bitprophet
Member

Actually, this is not quite the right fix, it hides the error that is naturally raised on no glob matches.

The real bug is in fabric.sftp.SFTP.glob.

Wrote a test to prove this issue exists & another one to enforce the "errors on glob miss" behavior; will merge shortly.

@bitprophet
Member

Also I don't see that this does fix #935 really, it doesn't make directory globbing function or document that it's not implemented =/

@bitprophet bitprophet added a commit that referenced this pull request Aug 22, 2016
@bitprophet bitprophet Tests added re #1470 0164dc6
@bitprophet bitprophet added a commit that closed this pull request Aug 22, 2016
@bitprophet bitprophet Fix #1470 and add changelog 1bb422f
@bitprophet
Member

Put in a "better" fix that updates sftp.glob to return empty list when no matches, then an explicit test for that situation in get which raises a similar IOError to the old behavior.

I also tested OpenSSH's sftp to make sure that it does itself error out when globs fail to find anything - and they do. (Otherwise I might have just omitted the explicit IOError...)

@bitprophet
Member

Grump, that breaks other stuff (like grabbing whole directories). So glad I am getting rid of this horrible get/put shite in 2.0 :( Reimplementing SFTP/rsync has been nothing but pain.

It looks like I can address the other breakage by removing the isdir test entirely; this all smells like organically decomposing code. Certainly, grabbing paths which are directories, still works recursively now, with no need to use globbing to obtain their contents (which I suspect was the original goal of that statement).

@shashurup

I agree that returning just empty list from glob() would be resonable. However it is considered natural glob behaviour to return the pattern itself when there are no matches, take a look, for example, at bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment