Skip to content

Commit 386a084

Browse files
authored
Create parent directories in get_file (#1282)
* Create parent directories in get_file * Use LocalFileSystem.makedirs
1 parent d69899d commit 386a084

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

fsspec/implementations/tests/memory/memory_test.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
import fsspec.tests.abstract as abstract
42
from fsspec.implementations.tests.memory.memory_fixtures import MemoryFixtures
53

@@ -9,21 +7,7 @@ class TestMemoryCopy(abstract.AbstractCopyTests, MemoryFixtures):
97

108

119
class TestMemoryGet(abstract.AbstractGetTests, MemoryFixtures):
12-
@pytest.mark.skip(reason="Bug: does not auto-create new directory")
13-
def test_get_file_to_new_directory(self):
14-
pass
15-
16-
@pytest.mark.skip(reason="Bug: does not auto-create new directory")
17-
def test_get_file_to_file_in_new_directory(self):
18-
pass
19-
20-
@pytest.mark.skip(reason="Bug: does not auto-create new directory")
21-
def test_get_glob_to_new_directory(self):
22-
pass
23-
24-
@pytest.mark.skip(reason="Bug: does not auto-create new directory")
25-
def test_get_list_of_files_to_new_directory(self):
26-
pass
10+
pass
2711

2812

2913
class TestMemoryPut(abstract.AbstractPutTests, MemoryFixtures):

fsspec/spec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,16 @@ def get_file(
861861
self, rpath, lpath, callback=_DEFAULT_CALLBACK, outfile=None, **kwargs
862862
):
863863
"""Copy single remote file to local"""
864+
from .implementations.local import LocalFileSystem
865+
864866
if isfilelike(lpath):
865867
outfile = lpath
866868
elif self.isdir(rpath):
867869
os.makedirs(lpath, exist_ok=True)
868870
return None
869871

872+
LocalFileSystem(auto_mkdir=True).makedirs(self._parent(lpath), exist_ok=True)
873+
870874
with self.open(rpath, "rb", **kwargs) as f1:
871875
if outfile is None:
872876
outfile = open(lpath, "wb")

0 commit comments

Comments
 (0)