~sschwarzer/ftputil#23: 
Add an option to (try to) list hidden files, too

#Info

ftputil version: 2.2.2

python: 2.5.1

ftpserver: any, (i used proftpd on localhost)

OS: Linux julian-laptop 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux

#Problem

Currently hidden files on the remote host are not listed. it would be nice if (maybe as an option to be set by a flag) the ftp DIR command could be called with "-a [path]" instead of "[path]" as an argument.

Currently i have a work around by changing ftputil.py, line 748 from

ftp_error._try_with_oserror(self._session.dir, path, callback)

to

ftp_error._try_with_oserror(self._session.dir, '-a '+path, callback)

I'm not sure how generic this options works across servers with different OS's though.

-- cheers,

julian

Status
RESOLVED FIXED
Submitter
ftputiluser (unverified)
Assigned to
No-one
Submitted
16 years ago
Updated
16 years ago
Labels
enhancement library

schwa (unverified) 16 years ago · edit

This topic has has been brought up ​on the mailing list, and because of the problems mentioned there, I tend to refrain from adding the requested support for hidden files.

I set the resolution to "wontfix" but that's not necessarily my final word, but for now, it is. ;-)

schwa (unverified) 11 years ago · edit

As this topic has been brought up in ticket #63 again, I reopen the ticket. I plan to implement an auto-probing feature as described in [comment 12](https://todo.sr.ht/~sschwarzer/ftputil/63 "Comment 12 for #63: defect: ftp_sync break on wrong mkdir exception (closed: invalid)") of ticket #63.

schwa (unverified) 11 years ago · edit

I have implemented auto-probing of LIST's -a option as of changeset ac808dc5d241b02249e86e632b933e8489cdfabe.

Note a few caveats:

  • All servers I tried seem to ignore LIST options they don't know. So if ftputil finds the option is accepted, that doesn't mean that it'll have any effect.

  • In theory the server might consider the option, but do something different with it than displaying hidden entries.

  • Even if the server software supports the -a option, the server might be configured to ignore it.

  • There may be rare programs which rely on "hidden" entries not being displayed. In that case, please change your code. As a crude workaround, you can use ftp_host._accepts_list_a_option = False right after the login. However, this may stop working some day, so you should really adapt your code.

  • There's an anomaly with directory entries which start with a hyphen. For example, if you try to list a line for a file named "-a", the server will interpret "LIST -a" or even "LIST -a -a" as a LIST for the whole directory. The entry "-a" will be displayed though. However, this shouldn't have any effect if you only use ftputil's official API.

Register here or Log in to comment, or comment via email.