Blame SOURCES/BZ-1410234-downloadonly-unlink-tmp-files.patch

5e9bef
diff -up yum-3.4.3/yum/drpm.py.orig yum-3.4.3/yum/drpm.py
5e9bef
--- yum-3.4.3/yum/drpm.py.orig	2019-03-27 16:55:57.846748074 +0100
5e9bef
+++ yum-3.4.3/yum/drpm.py	2019-03-27 16:56:28.012138396 +0100
5e9bef
@@ -270,7 +270,11 @@ class DeltaInfo:
5e9bef
                 # done with drpm file, unlink when local
5e9bef
                 if po.localpath.startswith(po.repo.pkgdir):
5e9bef
                     os.unlink(po.localpath)
5e9bef
-                po.localpath = po.rpm.localpath # for --downloadonly
5e9bef
+                # rename the rpm if --downloadonly
5e9bef
+                if po.rpm.localpath.endswith('.tmp'):
5e9bef
+                    rpmfile = po.rpm.localpath.rsplit('.', 2)[0]
5e9bef
+                    os.rename(po.rpm.localpath, rpmfile)
5e9bef
+                    po.rpm.localpath = rpmfile
5e9bef
             num += 1
5e9bef
 
5e9bef
             # when blocking, one is enough
5e9bef
diff -up yum-3.4.3/yum/__init__.py.orig yum-3.4.3/yum/__init__.py
5e9bef
--- yum-3.4.3/yum/__init__.py.orig	2019-03-27 16:55:58.035750519 +0100
5e9bef
+++ yum-3.4.3/yum/__init__.py	2019-03-27 16:56:28.012138396 +0100
5e9bef
@@ -2435,6 +2435,8 @@ much more problems).
5e9bef
         errors = {}
5e9bef
         def adderror(po, msg):
5e9bef
             errors.setdefault(po, []).append(msg)
5e9bef
+            if po.localpath.endswith('.tmp'):
5e9bef
+                misc.unlink_f(po.localpath) # won't resume this..
5e9bef
 
5e9bef
         #  We close the history DB here because some plugins (presto) use
5e9bef
         # threads. And sqlite really doesn't like threads. And while I don't
5e9bef
@@ -2546,6 +2548,10 @@ much more problems).
5e9bef
 
5e9bef
                 def checkfunc(obj, po=po):
5e9bef
                     self.verifyPkg(obj, po, 1)
5e9bef
+                    if po.localpath.endswith('.tmp'):
5e9bef
+                        rpmfile = po.localpath.rsplit('.', 2)[0]
5e9bef
+                        os.rename(po.localpath, rpmfile)
5e9bef
+                        po.localpath = rpmfile
5e9bef
                     local_size[0] += po.size
5e9bef
                     if hasattr(urlgrabber.progress, 'text_meter_total_size'):
5e9bef
                         urlgrabber.progress.text_meter_total_size(remote_size,
5e9bef
@@ -2584,29 +2590,21 @@ much more problems).
5e9bef
                 except Errors.RepoError, e:
5e9bef
                     adderror(po, exception2msg(e))
5e9bef
             if async:
5e9bef
-                urlgrabber.grabber.parallel_wait()
5e9bef
+                try:
5e9bef
+                    urlgrabber.grabber.parallel_wait()
5e9bef
+                except KeyboardInterrupt:
5e9bef
+                    for po in remote_pkgs:
5e9bef
+                        if po.localpath.endswith('.tmp'):
5e9bef
+                            misc.unlink_f(po.localpath)
5e9bef
+                        elif isinstance(po, DeltaPackage) and po.rpm.localpath.endswith('.tmp'):
5e9bef
+                            misc.unlink_f(po.rpm.localpath)
5e9bef
+                    raise
5e9bef
             presto.dequeue_all()
5e9bef
             presto.wait()
5e9bef
 
5e9bef
             if hasattr(urlgrabber.progress, 'text_meter_total_size'):
5e9bef
                 urlgrabber.progress.text_meter_total_size(0)
5e9bef
 
5e9bef
-            if downloadonly:
5e9bef
-                for po in remote_pkgs:
5e9bef
-                    if not po.localpath.endswith('.tmp'):
5e9bef
-                        # file:// repos don't "download"
5e9bef
-                        continue
5e9bef
-                    if po in errors:
5e9bef
-                        # we may throw away partial file here- but we don't lock,
5e9bef
-                        # so can't rename tempfile to rpmfile safely
5e9bef
-                        misc.unlink_f(po.localpath)
5e9bef
-                    else:
5e9bef
-                        # verifyPkg() didn't complain, so (potentially)
5e9bef
-                        # overwriting another copy should not be a problem
5e9bef
-                        rpmfile = po.localpath.rsplit('.', 2)[0]
5e9bef
-                        os.rename(po.localpath, rpmfile)
5e9bef
-                        po.localpath = rpmfile
5e9bef
-                    
5e9bef
             fatal = False
5e9bef
             for po in errors:
5e9bef
                 if not isinstance(po, DeltaPackage):