Skip to content

Commit 8b837b9

Browse files
refactor: remove protocol=='file' special case in exists() and isdir()
fsspec's local filesystem already handles exists() and isdir() correctly for both files and directories. The protocol-specific branches were unnecessary — self.fs.exists() and self.fs.isdir() work uniformly across all backends including local files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e9f60e8 commit 8b837b9

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/datajoint/storage.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def get_buffer(self, remote_path: str | PurePosixPath) -> bytes:
555555

556556
def exists(self, remote_path: str | PurePosixPath) -> bool:
557557
"""
558-
Check if a file exists in storage.
558+
Check if a path (file or directory) exists in storage.
559559
560560
Parameters
561561
----------
@@ -565,15 +565,11 @@ def exists(self, remote_path: str | PurePosixPath) -> bool:
565565
Returns
566566
-------
567567
bool
568-
True if file exists.
568+
True if the path exists.
569569
"""
570570
full_path = self._full_path(remote_path)
571571
logger.debug(f"exists: {self.protocol}:{full_path}")
572-
573-
if self.protocol == "file":
574-
return Path(full_path).exists()
575-
else:
576-
return self.fs.exists(full_path)
572+
return self.fs.exists(full_path)
577573

578574
def isdir(self, remote_path: str | PurePosixPath) -> bool:
579575
"""
@@ -590,10 +586,7 @@ def isdir(self, remote_path: str | PurePosixPath) -> bool:
590586
True if the path is a directory.
591587
"""
592588
full_path = self._full_path(remote_path)
593-
if self.protocol == "file":
594-
return Path(full_path).is_dir()
595-
else:
596-
return self.fs.isdir(full_path)
589+
return self.fs.isdir(full_path)
597590

598591
def remove(self, remote_path: str | PurePosixPath) -> None:
599592
"""

0 commit comments

Comments
 (0)