diff -Nru ubuntu-dev-tools-0.193ubuntu4~22.04.1/debian/changelog ubuntu-dev-tools-0.193ubuntu4~22.04.2/debian/changelog --- ubuntu-dev-tools-0.193ubuntu4~22.04.1/debian/changelog 2023-05-31 00:58:54.000000000 +0000 +++ ubuntu-dev-tools-0.193ubuntu4~22.04.2/debian/changelog 2023-07-06 12:20:23.000000000 +0000 @@ -1,3 +1,11 @@ +ubuntu-dev-tools (0.193ubuntu4~22.04.2) jammy; 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 13:09:21 +0100 + ubuntu-dev-tools (0.193ubuntu4~22.04.1) jammy; urgency=medium * Backport current ubuntu-dev-tools to jammy. LP: #2021910. diff -Nru ubuntu-dev-tools-0.193ubuntu4~22.04.1/ubuntutools/misc.py ubuntu-dev-tools-0.193ubuntu4~22.04.2/ubuntutools/misc.py --- ubuntu-dev-tools-0.193ubuntu4~22.04.1/ubuntutools/misc.py 2023-05-30 16:47:58.000000000 +0000 +++ ubuntu-dev-tools-0.193ubuntu4~22.04.2/ubuntutools/misc.py 2023-07-06 12:20:17.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)