mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
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
|
return dl_path
|
||||||
|
|
||||||
with_progress = not silent and not app.is_disabled_progressbar()
|
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:
|
try:
|
||||||
with LockFile(dl_path):
|
with LockFile(dl_path):
|
||||||
try:
|
try:
|
||||||
@ -86,9 +86,11 @@ class PackageManagerDownloadMixin(object):
|
|||||||
raise e
|
raise e
|
||||||
if checksum:
|
if checksum:
|
||||||
fd.verify(checksum)
|
fd.verify(checksum)
|
||||||
shutil.copyfile(tmp_path, dl_path)
|
os.close(tmp_fd)
|
||||||
|
os.rename(tmp_path, dl_path)
|
||||||
finally:
|
finally:
|
||||||
if os.path.isfile(tmp_path):
|
if os.path.isfile(tmp_path):
|
||||||
|
os.close(tmp_fd)
|
||||||
os.remove(tmp_path)
|
os.remove(tmp_path)
|
||||||
|
|
||||||
assert os.path.isfile(dl_path)
|
assert os.path.isfile(dl_path)
|
||||||
|
@ -64,6 +64,10 @@ class RegistryFileMirrorsIterator(object):
|
|||||||
response.headers.get("X-PIO-Content-SHA256"),
|
response.headers.get("X-PIO-Content-SHA256"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
""" For Python 2 compatibility """
|
||||||
|
return self.__next__()
|
||||||
|
|
||||||
def get_http_client(self):
|
def get_http_client(self):
|
||||||
if self._base_url not in RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES:
|
if self._base_url not in RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES:
|
||||||
RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES[
|
RegistryFileMirrorsIterator.HTTP_CLIENT_INSTANCES[
|
||||||
|
@ -71,7 +71,7 @@ def test_find_pkg_root(isolated_pio_core, tmpdir_factory):
|
|||||||
# library manager should create "library.json"
|
# library manager should create "library.json"
|
||||||
lm = LibraryPackageManager()
|
lm = LibraryPackageManager()
|
||||||
spec = PackageSpec("custom-name@1.0.0")
|
spec = PackageSpec("custom-name@1.0.0")
|
||||||
pkg_root = lm.find_pkg_root(pkg_dir, spec)
|
pkg_root = lm.find_pkg_root(str(pkg_dir), spec)
|
||||||
manifest_path = os.path.join(pkg_root, "library.json")
|
manifest_path = os.path.join(pkg_root, "library.json")
|
||||||
assert os.path.realpath(str(root_dir)) == os.path.realpath(pkg_root)
|
assert os.path.realpath(str(root_dir)) == os.path.realpath(pkg_root)
|
||||||
assert os.path.isfile(manifest_path)
|
assert os.path.isfile(manifest_path)
|
||||||
|
Reference in New Issue
Block a user