|
40 | 40 | from .path import basename
|
41 | 41 | from .path import normpath
|
42 | 42 | from .path import split
|
| 43 | +from .time import epoch_to_datetime |
43 | 44 | from . import _ftp_parse as ftp_parse
|
44 | 45 |
|
45 | 46 | if typing.TYPE_CHECKING:
|
@@ -572,6 +573,12 @@ def supports_mlst(self):
|
572 | 573 | """bool: whether the server supports MLST feature."""
|
573 | 574 | return "MLST" in self.features
|
574 | 575 |
|
| 576 | + @property |
| 577 | + def supports_mdtm(self): |
| 578 | + # type: () -> bool |
| 579 | + """bool: whether the server supports the MDTM feature.""" |
| 580 | + return "MDTM" in self.features |
| 581 | + |
575 | 582 | def create(self, path, wipe=False):
|
576 | 583 | # type: (Text, bool) -> bool
|
577 | 584 | _path = self.validatepath(path)
|
@@ -692,8 +699,21 @@ def getmeta(self, namespace="standard"):
|
692 | 699 | if namespace == "standard":
|
693 | 700 | _meta = self._meta.copy()
|
694 | 701 | _meta["unicode_paths"] = "UTF8" in self.features
|
| 702 | + _meta["supports_mtime"] = "MDTM" in self.features |
695 | 703 | return _meta
|
696 | 704 |
|
| 705 | + def getmodified(self, path): |
| 706 | + # type: (Text) -> Optional[datetime.datetime] |
| 707 | + if self.supports_mdtm: |
| 708 | + _path = self.validatepath(path) |
| 709 | + with self._lock: |
| 710 | + with ftp_errors(self, path=path): |
| 711 | + cmd = "MDTM " + _encode(_path, self.ftp.encoding) |
| 712 | + response = self.ftp.sendcmd(cmd) |
| 713 | + mtime = self._parse_ftp_time(response.split()[1]) |
| 714 | + return epoch_to_datetime(mtime) |
| 715 | + return super(FTPFS, self).getmodified(path) |
| 716 | + |
697 | 717 | def listdir(self, path):
|
698 | 718 | # type: (Text) -> List[Text]
|
699 | 719 | _path = self.validatepath(path)
|
|
0 commit comments