diff --git a/pyproject.toml b/pyproject.toml index 2641f5f..6646c56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,8 +11,8 @@ keywords = ["snakemake", "plugin", "storage", "filesystem", "rsync"] [tool.poetry.dependencies] python = "^3.11" -snakemake-interface-common = "^1.14.2" -snakemake-interface-storage-plugins = "^3.0.0" +snakemake-interface-common = "^1.17.0" +snakemake-interface-storage-plugins = "^3.1.0" sysrsync = "^1.1.1" reretry = "^0.11.8" diff --git a/snakemake_storage_plugin_fs/__init__.py b/snakemake_storage_plugin_fs/__init__.py index daaa8d2..8d4b0aa 100644 --- a/snakemake_storage_plugin_fs/__init__.py +++ b/snakemake_storage_plugin_fs/__init__.py @@ -23,6 +23,7 @@ StorageObjectRead, StorageObjectWrite, StorageObjectGlob, + StorageObjectTouch, ) from snakemake_interface_storage_plugins.io import ( IOCacheStorageInterface, @@ -30,6 +31,7 @@ Mtime, ) from snakemake_interface_storage_plugins.settings import StorageProviderSettingsBase +from snakemake_interface_common.utils import lutime @dataclass @@ -137,7 +139,9 @@ def wrapper(self, *args, **kwargs): # storage (e.g. because it is read-only see # snakemake-storage-http for comparison), remove the corresponding base classes # from the list of inherited items. -class StorageObject(StorageObjectRead, StorageObjectWrite, StorageObjectGlob): +class StorageObject( + StorageObjectRead, StorageObjectWrite, StorageObjectGlob, StorageObjectTouch +): # For compatibility with future changes, you should not overwrite the __init__ # method. Instead, use __post_init__ to set additional attributes and initialize # futher stuff. @@ -262,3 +266,15 @@ def _stat(self, follow_symlinks: bool = True): # We don't want the cached variant (Path.stat), as we cache ourselves in # inventory and afterwards the information may change. return os.stat(self.query_path, follow_symlinks=follow_symlinks) + + def touch(self): + if self.query_path.exists(): + if self.query_path.is_dir(): + flag = self.query_path / ".snakemake_timestamp" + # Create the flag file if it doesn't exist + if not flag.exists(): + with open(flag, "w"): + pass + lutime(flag, None) + else: + lutime(str(self.query_path), None) diff --git a/tests/tests.py b/tests/tests.py index eae3bae..3f0dc4a 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -10,6 +10,7 @@ class TestStorageNoSettings(TestStorageBase): __test__ = True retrieve_only = False + touch = True def get_query(self, tmp_path) -> str: parent = f"{tmp_path}/storage/test/"