diff -Nru ubuntu-dev-tools-0.193ubuntu4~20.04.2/debian/changelog ubuntu-dev-tools-0.193ubuntu4~20.04.3/debian/changelog --- ubuntu-dev-tools-0.193ubuntu4~20.04.2/debian/changelog 2023-06-07 05:00:09.000000000 +0000 +++ ubuntu-dev-tools-0.193ubuntu4~20.04.3/debian/changelog 2023-07-06 12:20:26.000000000 +0000 @@ -1,3 +1,11 @@ +ubuntu-dev-tools (0.193ubuntu4~20.04.3) focal; urgency=medium + + * ubuntutools/misc.py: swap iter_content for raw stream with + "Accept-Encoding: identity" to fix .diff.gz downloads (LP: #2025748). This + fixes a regression caused by the backport of 0.193 that included this bug. + + -- Robie Basak Thu, 06 Jul 2023 12:14:00 +0000 + ubuntu-dev-tools (0.193ubuntu4~20.04.2) focal; urgency=medium * ubuntutools/misc.py: back out a change that's incompatible with python diff -Nru ubuntu-dev-tools-0.193ubuntu4~20.04.2/ubuntutools/misc.py ubuntu-dev-tools-0.193ubuntu4~20.04.3/ubuntutools/misc.py --- ubuntu-dev-tools-0.193ubuntu4~20.04.2/ubuntutools/misc.py 2023-06-07 05:00:01.000000000 +0000 +++ ubuntu-dev-tools-0.193ubuntu4~20.04.3/ubuntutools/misc.py 2023-07-06 12:20:26.000000000 +0000 @@ -348,7 +348,11 @@ with tempfile.TemporaryDirectory() as tmpdir: tmpdst = Path(tmpdir) / "dst" try: - with requests.get(src, stream=True, timeout=60, auth=auth) as fsrc: + # We must use "Accept-Encoding: identity" so that Launchpad doesn't + # compress changes files. See LP: #2025748. + with requests.get( + src, stream=True, timeout=60, auth=auth, headers={"accept-encoding": "identity"} + ) as fsrc: with tmpdst.open("wb") as fdst: fsrc.raise_for_status() _download(fsrc, fdst, size, blocksize=blocksize) @@ -433,7 +437,16 @@ downloaded = 0 try: - for block in fsrc.iter_content(blocksize): + while True: + # We use fsrc.raw so that compressed files stay compressed as we + # write them to disk. For example, if this is a .diff.gz, then it + # needs to remain compressed and unmodified to remain valid as part + # of a source package later, even though Launchpad sends + # "Content-Encoding: gzip" and the requests library therefore would + # want to decompress it. See LP: #2025748. + block = fsrc.raw.read(blocksize) + if not block: + break fdst.write(block) downloaded += len(block) progress_bar.update(downloaded, size)