Hi,
I have been asked at answers.microsoft.com to ask my question here.
I use a pretty simple python script (also tried a nodejs script) like the one at the end to find all files in a directory and its subdirectories together with their file size and modified time. Therefore the script uses stat syscall to retrieve information
about a path: type (regular file, directory etc.), size, modified time.
If I run the script on a local folder on Windows 10, Windows 7 and Ubuntu everything works fine. If I run the script on Windows 7 or Ubuntu on a folder that is a mounted samba share, everything works fine, too.
However, if I run the script on Windows 10 on a folder that is on a mounted samba share, things start to get weird. I get error messages like the following:
C:\Users\Biggie\Scripts>python test.py
Traceback (most recent call last):
File "test.py", line 10, in <module>
childs = listdir(next)
WindowsError: [Error 267] The directory name is invalid: 'y:\\some\\path\\file.jpg\\*.*'
This happens, because the result of the stat call states that the path is a directory, although it is a regular jpg file. If I start an interactive python or nodejs shell and call stat for the reported file, the return value looks ok this time
(correct type, size etc.). It looks like the samba client on Windows 10 bungles whentoo many stat calls are issued in a short time interval.
Is this a known problem? To me it looks like a fatal bug. Is there a way to get around is problem by using some Windows 10 settings?
In my case the script is actually the base for a backup application ... which will totally do the wrong thing if file sizes and types are returned incorrectly.
Note: I tested 2 Windows clients running Windows 10. The 3 tested samba servers are running Ubuntu using pretty much Ubuntu's default smbd configs (besides share definitions). I also tried to force SMB2 but that didn't change anything.
Appendix:
The python script. The nodejs script (not listed here) does pretty much the same thing:
from os import listdir, stat
from os.path import join
from stat import *
files = []
todo = ['y:\\'] # y:\\ is a mounted samba share
while len(todo) > 0:
next = todo.pop(0)
childs = listdir(next)
for child in childs:
childPath = join(next, child)
childStat = stat(childPath)
mode = childStat.st_mode
if S_ISREG(mode):
files.append(childStat)
elif S_ISDIR(mode):
todo.append(childPath)
print len(files) # Will not be called because error is thrown before on Windows 10