@@ -38,13 +38,11 @@ def __init__(self, path, accept_multiple=True):
3838
3939 def request (self , client , f , ** kwargs ):
4040 if kwargs .pop ('recursive' , False ):
41- return self .recursive (client , f , ** kwargs )
41+ return self .directory (client , f , recursive = True , ** kwargs )
4242 if isinstance (f , (list , tuple )):
4343 return self .multiple (client , f , ** kwargs )
4444 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 )
4846 else :
4947 return self .single (client , f , ** kwargs )
5048
@@ -65,7 +63,8 @@ def multiple(self, client, files, **kwargs):
6563 body , headers = multipart .stream_files (files )
6664 return client .request (self .path , data = body , headers = headers , ** kwargs )
6765
68- def recursive (self , client , dirname , fnpattern = '*' , ** kwargs ):
66+ def directory (self , client , dirname ,
67+ fnpattern = '*' , recursive = False , ** kwargs ):
6968 """
7069 Loads a directory recursively into IPFS, files are matched against the
7170 given pattern.
@@ -75,7 +74,7 @@ def recursive(self, client, dirname, fnpattern='*', **kwargs):
7574 "[%s] does not accept multiple files." % self .path )
7675 body , headers = multipart .stream_directory (dirname ,
7776 fnpattern = fnpattern ,
78- recursive = True )
77+ recursive = recursive )
7978 return client .request (self .path , data = body , headers = headers , ** kwargs )
8079
8180
0 commit comments