From 8b9fe85564ef1f8ef3a637380d7fa71b79a6f559 Mon Sep 17 00:00:00 2001 From: Ben <55319792+benrutter@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:50:35 +0100 Subject: [PATCH] modified method functionality added (#44) Co-authored-by: Ruslan Kuprieiev --- sshfs/spec.py | 7 +++++++ tests/test_sshfs.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/sshfs/spec.py b/sshfs/spec.py index abd5b43..8056dd4 100644 --- a/sshfs/spec.py +++ b/sshfs/spec.py @@ -148,6 +148,13 @@ async def _info(self, path, **kwargs): info["name"] = path return info + @wrap_exceptions + async def _modified(self, path: str, **kwargs) -> datetime: + path_info = await self._info(path) + return path_info["mtime"] + + modified = sync_wrapper(_modified) + @wrap_exceptions async def _mv(self, lpath, rpath, **kwargs): async with self._pool.get() as channel: diff --git a/tests/test_sshfs.py b/tests/test_sshfs.py index 47d4c12..c30bdfc 100644 --- a/tests/test_sshfs.py +++ b/tests/test_sshfs.py @@ -4,6 +4,7 @@ import tempfile import warnings from concurrent import futures +from datetime import datetime from pathlib import Path import fsspec @@ -339,6 +340,11 @@ def test_concurrency_for_raw_commands(fs, remote_dir): future.result() +def test_modified(fs, remote_dir): + modified = fs.modified(remote_dir) + assert isinstance(modified, datetime) + + def test_cat_file_sync(fs, remote_dir): # Define the content to write to the test file test_content = b"Test content for cat_file"