Skip to content

Commit 2eb83d0

Browse files
author
Martin Durant
committed
Do not ignote existing dir in local mkdir
1 parent c3dac4f commit 2eb83d0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

fsspec/implementations/local.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def __init__(self, auto_mkdir=False, **kwargs):
3333

3434
def mkdir(self, path, create_parents=True, **kwargs):
3535
path = self._strip_protocol(path)
36+
if self.exists(path):
37+
raise FileExistsError(path)
3638
if create_parents:
3739
self.makedirs(path, exist_ok=True)
3840
else:

fsspec/implementations/tests/test_local.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,14 @@ def test_strip_protocol_expanduser():
571571
assert not LocalFileSystem._strip_protocol("./").endswith("/")
572572

573573

574+
def test_mkdir_twice_faile(tmpdir):
575+
fn = os.path.join(tmpdir, "test")
576+
fs = fsspec.filesystem("file")
577+
fs.mkdir(fn)
578+
with pytest.raises(FileExistsError):
579+
fs.mkdir(fn)
580+
581+
574582
def test_iterable(tmpdir):
575583
data = b"a\nhello\noi"
576584
fn = os.path.join(tmpdir, "test")

0 commit comments

Comments
 (0)