diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2022-07-12 16:49:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 16:49:59 +0200 |
commit | 74e2625dcf61639fa6d63892115eb4ab35b85e58 (patch) | |
tree | 53900e48b6bd407f8f16e279f0e30c264c566ef3 /lib | |
parent | a4f05224687c4a783994104819c864d3c6e35449 (diff) | |
download | spack-74e2625dcf61639fa6d63892115eb4ab35b85e58.tar.gz spack-74e2625dcf61639fa6d63892115eb4ab35b85e58.tar.bz2 spack-74e2625dcf61639fa6d63892115eb4ab35b85e58.tar.xz spack-74e2625dcf61639fa6d63892115eb4ab35b85e58.zip |
compression.py: buffered copy (#31533)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/util/compression.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/spack/spack/util/compression.py b/lib/spack/spack/util/compression.py index cbd5beddec..859f4faa28 100644 --- a/lib/spack/spack/util/compression.py +++ b/lib/spack/spack/util/compression.py @@ -112,7 +112,7 @@ def _bunzip2(archive_file): import bz2 f_bz = bz2.BZ2File(archive_file, mode='rb') with open(archive_out, 'wb') as ar: - ar.write(f_bz.read()) + shutil.copyfileobj(f_bz, ar) f_bz.close() else: shutil.copy(archive_file, copy_path) @@ -139,7 +139,8 @@ def _gunzip(archive_file): import gzip f_in = gzip.open(archive_file, "rb") with open(destination_abspath, "wb") as f_out: - f_out.write(f_in.read()) + shutil.copyfileobj(f_in, f_out) + f_in.close() else: _system_gunzip(archive_file) return destination_abspath @@ -200,7 +201,7 @@ def _lzma_decomp(archive_file): archive_out = os.path.join(os.getcwd(), decompressed_file) with open(archive_out, 'wb') as ar: with lzma.open(archive_file) as lar: - ar.write(lar.read()) + shutil.copyfileobj(lar, ar) else: if is_windows: return _7zip(archive_file) |