Closed ekarademir closed 3 years ago
@ekarademir I have the same problem I had to use a try except in the base code to pass the issue about permission, I could over come this with the documentation of this issue in python:
https://bugs.python.org/issue43657
my code, as soon as I can I will open an MR:
pymongo\downloader__init__.py
# line 245
try:
shutil.rmtree(bin_dir)
except PermissionError as error:
shutil.rmtree(bin_dir, onerror=remove_readonly)
def remove_readonly(func, path, _):
"Clear the readonly bit and reattempt the removal"
os.chmod(path, stat.S_IWRITE)
func(path)
an Warning was raised after that but I am investigating it
Thank you @LeonardoLeano333 I'm interested in your findings after investigation. We are not aiming Windows as a primary platform to use this library but never the less, full compatibility will be great.
During #9 I realised that Python doesn't handle
chmod
operations very well on Windows. It simply creates read-only files.Although this is not a problem for executing the downloaded binary, it becomes a problem if we try to overwrite. This is not a blocking issue, because the folders are separated by their versions, and once a version is downloaded, there wouldn't be a reason to overwrite contents other than user explicitly deleting them, in which case, there is no issue.
This is more of a further goal in the future, if we need more file system tooling.