diff --git a/smbclientng/core/SMBSession.py b/smbclientng/core/SMBSession.py index f55f8f8..49ec57d 100644 --- a/smbclientng/core/SMBSession.py +++ b/smbclientng/core/SMBSession.py @@ -250,15 +250,13 @@ def recurse_action(paths=[], depth=0, callback=None): for entry in entries: if entry.is_directory(): - callback(entry, path + ntpath.sep + entry.get_longname() + ntpath.sep, depth) + fullpath = path + ntpath.sep + entry.get_longname() + ntpath.sep + next_directories_to_explore.append(fullpath) else: - callback(entry, path + ntpath.sep + entry.get_longname(), depth) - - # Next directories to explore - for entry in entries: - if entry.is_directory(): - next_directories_to_explore.append(path + ntpath.sep + entry.get_longname() + ntpath.sep) - + fullpath = path + ntpath.sep + entry.get_longname() + fullpath = re.sub(r'\\\\+', r'\\', fullpath) + callback(entry, fullpath, depth) + return next_directories_to_explore # if callback is not None: