@@ -38,13 +38,11 @@ def __init__(self, path, accept_multiple=True):
38
38
39
39
def request (self , client , f , ** kwargs ):
40
40
if kwargs .pop ('recursive' , False ):
41
- return self .recursive (client , f , ** kwargs )
41
+ return self .directory (client , f , recursive = True , ** kwargs )
42
42
if isinstance (f , (list , tuple )):
43
43
return self .multiple (client , f , ** kwargs )
44
44
if isinstance (f , six .string_types ) and os .path .isdir (f ):
45
- ls = [os .path .join (f , p ) for p in os .listdir (f )]
46
- fs = [p for p in ls if os .path .isfile (p )]
47
- return self .multiple (client , fs , ** kwargs )
45
+ return self .directory (client , f , ** kwargs )
48
46
else :
49
47
return self .single (client , f , ** kwargs )
50
48
@@ -65,7 +63,8 @@ def multiple(self, client, files, **kwargs):
65
63
body , headers = multipart .stream_files (files )
66
64
return client .request (self .path , data = body , headers = headers , ** kwargs )
67
65
68
- def recursive (self , client , dirname , fnpattern = '*' , ** kwargs ):
66
+ def directory (self , client , dirname ,
67
+ fnpattern = '*' , recursive = False , ** kwargs ):
69
68
"""
70
69
Loads a directory recursively into IPFS, files are matched against the
71
70
given pattern.
@@ -75,7 +74,7 @@ def recursive(self, client, dirname, fnpattern='*', **kwargs):
75
74
"[%s] does not accept multiple files." % self .path )
76
75
body , headers = multipart .stream_directory (dirname ,
77
76
fnpattern = fnpattern ,
78
- recursive = True )
77
+ recursive = recursive )
79
78
return client .request (self .path , data = body , headers = headers , ** kwargs )
80
79
81
80
0 commit comments