Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for fs.modified #44

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sshfs/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sshfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tempfile
import warnings
from concurrent import futures
from datetime import datetime
from pathlib import Path

import fsspec
Expand Down Expand Up @@ -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"
Expand Down
Loading