Custom Query (120 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (7 - 9 of 120)

1 2 3 4 5 6 7 8 9 10 11 12 13
Ticket Resolution Summary Owner Reporter
#130 fixed Consider making some arguments keyword-only schwa schwa
Description

ftputil 4.0.0 will introduce backward-incompatible changes. One of these changes is dropping support for Python 2.

Since we're breaking backward compatibility anyway and no longer need to support Python 2, this is a good time to check which arguments should become keyword-only arguments.

#127 wontfix Many `cwd` calls on the FTP session object schwa schwa
Description

Migration to the new mock testing approach (scripted sessions) showed that there are frequent ftplib.FTP.cwd calls in a row. The reason is that every time _robust_ftp_command

    def _robust_ftp_command(self, command, path, descend_deeply=False):
        """
        Run an FTP command on a path. The return value of the method
        is the return value of the command.

        If `descend_deeply` is true (the default is false), descend
        deeply, i. e. change the directory to the end of the path.
        """
        # If we can't change to the yet-current directory, the code
        # below won't work (see below), so in this case rather raise
        # an exception than giving wrong results.
        self._check_inaccessible_login_directory()
        # Some FTP servers don't behave as expected if the directory
        # portion of the path contains whitespace; some even yield
        # strange results if the command isn't executed in the
        # current directory. Therefore, change to the directory
        # which contains the item to run the command on and invoke
        # the command just there.
        #
        # Remember old working directory.
        old_dir = self.getcwd()
        try:
            if descend_deeply:
                # Invoke the command in (not: on) the deepest directory.
                self.chdir(path)
                # Workaround for some servers that give recursive
                # listings when called with a dot as path; see issue #33,
                # http://ftputil.sschwarzer.net/trac/ticket/33
                return command(self, "")
            else:
                # Invoke the command in the "next to last" directory.
                head, tail = self.path.split(path)
                self.chdir(head)
                return command(self, tail)
        finally:
            self.chdir(old_dir)

is used, we have one cwd call in _check_inaccessible_login_directory (which should be only needed once after opening the session), a second cwd to descend into the possibly nested directory and finally a third cwd to restore the old directory after the "descent".

In the tests it looks like cwd / is used all the time, but this is only because the directory we start from is /, so the directory into which we "descend" and which we restore later in the method happen to be the same.

Also keep in mind that most FTP sessions transfer files, and I imagine the overall network traffic and hence the needed time for the file transfers will outweigh the time for the cwd calls.

#126 invalid Items are stored in the cache even if it's disabled schwa schwa
Description

In ftputil.stat, we have the code

    def _stat_results_from_dir(self, path):
        """
        Yield stat results extracted from the directory listing `path`.
        Omit the special entries for the directory itself and its parent
        directory.
        """
        lines = self._host_dir(path)
        # `cache` is the "high-level" `StatCache` object whereas
        # `cache._cache` is the "low-level" `LRUCache` object.
        cache = self._lstat_cache
        # Auto-grow cache if the cache up to now can't hold as many
        # entries as there are in the directory `path`.
        if cache._enabled and len(lines) >= cache._cache.size:
            new_size = int(math.ceil(1.1 * len(lines)))
            cache.resize(new_size)
        # Yield stat results from lines.
        for line in lines:
            if self._parser.ignores_line(line):
                continue
            # Although for a `listdir` call we're only interested in
            # the names, use the `time_shift` parameter to store the
            # correct timestamp values in the cache.
            stat_result = self._parser.parse_line(line,
                                                  self._host.time_shift())
            # Skip entries "." and "..".
            if stat_result._st_name in [self._host.curdir, self._host.pardir]:
                continue
            loop_path = self._path.join(path, stat_result._st_name)
            self._lstat_cache[loop_path] = stat_result
            yield stat_result

According to the second to last line, the stat_result is stored in the cache even if it's disabled.

Usually this will be harmless regardless of whether a user would expect it. The only downside is that if there are many cache assignments like that, the cache won't be expanded because of the cache._enabled test above and the cache logic will remove and replace older cache entries all the time. That said, if the user disabled the stat cache with FTPHost.stat_cache.disable() (the cache is enabled by default), we have much more serious performance problems because the cache isn't used and there will be many roundtrips to the FTP server because of this.

Due to this tradeoff, I think this is a very minor issue. Still, the fix should be very easy by adding an if statement.

1 2 3 4 5 6 7 8 9 10 11 12 13
Note: See TracQuery for help on using queries.