forked from platformio/platformio-core
Fix "PermissionError: [WinError 32] The process cannot access the file" on Windows
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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[
|
||||
|
||||
Reference in New Issue
Block a user