Changeset 1678:4027740cdd2d


Ignore:
Timestamp:
Oct 28, 2017, 7:23:06 PM (14 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
amend_source:
6079a9531a64b1bdc9a99cabc43bf7c45467f280
Message:
Apply `normpath` before comparing paths

In both `isfile` and `isdir` of `ftputil.path._Path`, there's a
workaround in case we can't go to a parent directory of the current
directory.

Call `normpath` on the `isfile`/`isdir` path argument before comparing
with `self._host.getcwd()`. This makes sure that we compare correctly
if the paths aren't strictly equal but only semantically equal, i. e.
referring to the same actual file system path.

Don't use `samefile` here because this implicitly tries to call
`stat`. This is exactly what we try to _avoid_ when applying the
workaround.

For now, don't create unit tests because these would be probably
rather awkward.

ticket: 113
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/path.py

    r1564 r1678  
    132132        path = ftputil.tool.as_unicode(path)
    133133        # Workaround if we can't go up from the current directory
    134         if path == self._host.getcwd():
     134        if self.normpath(path) == self._host.getcwd():
    135135            return False
    136136        try:
     
    153153        path = ftputil.tool.as_unicode(path)
    154154        # Workaround if we can't go up from the current directory
    155         if path == self._host.getcwd():
     155        if self.normpath(path) == self._host.getcwd():
    156156            return True
    157157        try:
Note: See TracChangeset for help on using the changeset viewer.