From 94d6a01ccab6c58144e864fea7b8e77ada6a61a4 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 13 May 2021 19:42:40 +0200 Subject: [PATCH] Use file mtime in local crawler --- PFERD/crawlers/local.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PFERD/crawlers/local.py b/PFERD/crawlers/local.py index e80472e..fb08cc9 100644 --- a/PFERD/crawlers/local.py +++ b/PFERD/crawlers/local.py @@ -1,4 +1,5 @@ import asyncio +import datetime from pathlib import Path, PurePath from ..conductor import TerminalConductor @@ -48,12 +49,14 @@ class LocalCrawler(Crawler): async def _crawl_file(self, path: Path, pure: PurePath) -> None: async with self.download_bar(path) as bar: - bar.set_total(path.stat().st_size) - - dl = await self.download(pure) + stat = path.stat() + mtime = datetime.datetime.fromtimestamp(stat.st_mtime) + dl = await self.download(pure, mtime=mtime) if not dl: return + bar.set_total(stat.st_size) + async with dl as sink: with open(path, "rb") as f: while True: