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

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