Closed MWedl closed 2 years ago
I'm not opposed to the change I'm just curious what the use case is of calling from_path
here? It was only really added originally for smbclient.shutil.copytree
to support a use case it had.
I'm building a SMB share crawler which performs some permission and content checks. One of the main features is that crawling can be stopped and continued where it left off. Encountered files are also periodically re-checked to see if something changed. Therefore all paths are stored in a small SQLite DB. When visiting the path, SMBDirEntry.from_path()
is called. Files, directories and symlinks are handled differently by the crawler.
While testing I encountered a symlink which points to a local file. Because of that, a SMBLinkRedirectionError
is raised in SMBDirEntry.from_path()
as symlinks are always followed. This was before I could even check if the path is a symlink or not.
That's fair, if you are building the stat info from a path is there a reason why you aren't just calling stat
or lstat
manually? The main reason why SMBDirEntry
exists is for scandir
to provide a more efficient dir enumeration result with the ability to get more information as required by then calling stat
. If you already have the path you can bypass this by calling stat
directly.
The changes here are fine just trying to figure out the use case here and whether there's something missing in another function.
The reason why I am using SMBDirEntry
instead of raw stat()
results, are the methods is_dir()
, is_file()
and is_symlink()
.
stat()
supportsfollow_symlinks=False
passed inkwargs
, butSMBRawIO(path, **kwargs)
does not and raises an Exception.