Changeset 1711:766c15f83205


Ignore:
Timestamp:
Dec 25, 2018, 10:55:24 PM (9 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
histedit_source:
160218f7e8d5388866cabb8ce12f3d2f32ec82ca,bd2e407ea486f11e94d86b0419db5e02843089e1
Message:
Set `use_list_a_option` to `False` by default

See ticket #110 for the reasoning.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • doc/ftputil.txt

    r1698 r1711  
    458458Whether ftputil sees "hidden" files and directories (usually files or
    459459directories whose names start with a dot) depends on the FTP server
    460 configuration. By default, ftputil uses the ``-a`` option in the FTP
    461 ``LIST`` command to find hidden files. However, the server may ignore
    462 this.
    463 
    464 If using the ``-a`` option leads to problems, for example if an
    465 FTP server causes an exception, you may switch off the use of the
    466 option::
     460configuration. By default, ftputil does *not* use the ``-a`` option in
     461the FTP ``LIST`` command to find hidden files.
     462
     463To tell the server to list hidden directories and files, set
     464``FTPHost.use_list_a_option`` to ``True``::
    467465
    468466    ftp_host = ftputil.FTPHost(server, user, password, account,
    469467                               session_factory=ftplib.FTP)
    470     ftp_host.use_list_a_option = False
     468    ftp_host.use_list_a_option = True
     469
     470Caveats:
     471
     472- If the server doesn't understand the ``-a`` option at all, the
     473  server may interpret ``-a`` as the name of a file or directory,
     474  which can result in odd behavior. Therefore, use ``-a`` only if
     475  you're sure the server you're talking to supports it. Another
     476  approach is to have test code for ``-a`` support and fall back to
     477  not using the option.
     478
     479- Even if the server knows about the ``-a`` option, the server may
     480  be configured to ignore it.
    471481
    472482``FTPHost`` attributes and methods
  • ftputil/host.py

    r1688 r1711  
    9494        # `download_if_newer`).
    9595        self.set_time_shift(0.0)
    96         # Use `LIST -a` option by default. If this causes problems,
    97         # the user can set the attribute to `False`.
    98         warnings.warn(
    99           "`use_list_a_option` will default to `False` in ftputil 4.x.x",
    100           DeprecationWarning, stacklevel=2)
    101         self.use_list_a_option = True
     96        # Don't use `LIST -a` option by default. If the server doesn't
     97        # understand the `-a` option and interprets it as a path, the
     98        # results can be surprising. See ticket #110.
     99        self.use_list_a_option = False
    102100
    103101    def keep_alive(self):
  • test/test_real_ftp.py

    r1671 r1711  
    944944        # option is used.
    945945        host = self.host
    946         assert host.use_list_a_option
     946        assert not host.use_list_a_option
     947        directory_entries = host.listdir(host.curdir)
     948        assert ".hidden" not in directory_entries
     949        # Switch on showing of hidden paths.
     950        host.use_list_a_option = True
    947951        directory_entries = host.listdir(host.curdir)
    948952        assert ".hidden" in directory_entries
    949         host.use_list_a_option = False
    950         directory_entries = host.listdir(host.curdir)
    951         assert ".hidden" not in directory_entries
    952953
    953954    def _make_objects_to_be_garbage_collected(self):
Note: See TracChangeset for help on using the changeset viewer.