Fix "PermissionError: [WinError 32] The process cannot access the file" on Windows

This commit is contained in:
Ivan Kravets
2020-08-01 15:36:28 +03:00
parent a1970bbfe3
commit 41c2d64ef0
3 changed files with 9 additions and 3 deletions
+4 -2
View File
@@ -61,7 +61,7 @@ class PackageManagerDownloadMixin(object):
return dl_path
with_progress = not silent and not app.is_disabled_progressbar()
tmp_path = tempfile.mkstemp(dir=self.get_download_dir())[1]
tmp_fd, tmp_path = tempfile.mkstemp(dir=self.get_download_dir())
try:
with LockFile(dl_path):
try:
@@ -86,9 +86,11 @@ class PackageManagerDownloadMixin(object):
raise e
if checksum:
fd.verify(checksum)
shutil.copyfile(tmp_path, dl_path)
os.close(tmp_fd)
os.rename(tmp_path, dl_path)
finally:
if os.path.isfile(tmp_path):
os.close(tmp_fd)
os.remove(tmp_path)
assert os.path.isfile(dl_path)
+4
View File
@@ -64,6 +64,10 @@ class RegistryFileMirrorsIterator(object):
response.headers.get("X-PIO-Content-SHA256"),
)
def next(self):
""" For Python 2 compatibility """
return self.__next__()
def get_http_client(self):
if self._base_url not in RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES:
RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES[