richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/1761.patch

c0440e
From 06b0081220d7e85134c61e6c86e723eb4a34b535 Mon Sep 17 00:00:00 2001
c0440e
From: Matthew Almond <malmond@fb.com>
c0440e
Date: Fri, 30 Apr 2021 13:11:04 -0700
c0440e
Subject: [PATCH] Do not assume that a remote rpm is complete if present
c0440e
c0440e
We should not assume that a file present in the hashed directory for a remote
c0440e
url is complete if present.
c0440e
c0440e
This manifests in two ways:
c0440e
c0440e
1. `Can not load RPM file: ` if the headers are incomplete
c0440e
2. `Payload SHA256 digest: BAD` error otherwise
c0440e
c0440e
This isn't a common error in the field because most sites use `keepcache=0` in
c0440e
`dnf.conf`. On the latter error the broken RPM is deleted, and the next run
c0440e
will retry the download from scratch, and probably succeeding.
c0440e
c0440e
This impacts us because we use `keepcache=1` so once we get an interrupted
c0440e
download, we can't (automatically) recover.
c0440e
c0440e
The fix here forces us to try to download/resume the file even if present on
c0440e
disk, because we don't have any higher level metadata like digests to falsify
c0440e
downloads without network.
c0440e
c0440e
This change makes an explicit decision to try to be more correct instead of
c0440e
using an incomplete optimization.
c0440e
---
c0440e
 dnf/util.py | 2 --
c0440e
 1 file changed, 2 deletions(-)
c0440e
c0440e
diff --git a/dnf/util.py b/dnf/util.py
c0440e
index b9dcd47081..9f0eb4abd2 100644
c0440e
--- a/dnf/util.py
c0440e
+++ b/dnf/util.py
c0440e
@@ -88,8 +88,6 @@ def _urlopen_progress(url, conf, progress=None):
c0440e
     if progress is None:
c0440e
         progress = dnf.callback.NullDownloadProgress()
c0440e
     pload = dnf.repo.RemoteRPMPayload(url, conf, progress)
c0440e
-    if os.path.exists(pload.local_path):
c0440e
-        return pload.local_path
c0440e
     est_remote_size = sum([pload.download_size])
c0440e
     progress.start(1, est_remote_size)
c0440e
     targets = [pload._librepo_target()]