MCPcopy
hub / github.com/scrapy/scrapy / _stat_file

Method _stat_file

scrapy/pipelines/files.py:403–417  ·  view source on GitHub ↗
(self, path: str)

Source from the content-addressed store, hash-verified

401 )
402
403 def _stat_file(self, path: str) -> StatInfo:
404 try:
405 with FTP() as ftp:
406 ftp.connect(self.host, self.port)
407 ftp.login(self.username, self.password)
408 if self.USE_ACTIVE_MODE:
409 ftp.set_pasv(False)
410 file_path = f"{self.basedir}/{path}"
411 last_modified = float(ftp.voidcmd(f"MDTM {file_path}")[4:].strip())
412 m = hashlib.md5() # noqa: S324
413 ftp.retrbinary(f"RETR {file_path}", m.update)
414 return {"last_modified": last_modified, "checksum": m.hexdigest()}
415 # The file doesn't exist
416 except Exception:
417 return {}
418
419 def stat_file(
420 self, path: str, info: MediaPipeline.SpiderInfo

Callers

nothing calls this directly

Calls 2

loginMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected