movefile: remove source symlink/hardlink after mv
authorZac Medico <zmedico@gentoo.org>
Tue, 16 Apr 2013 14:00:45 +0000 (07:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 16 Apr 2013 14:00:45 +0000 (07:00 -0700)
pym/portage/util/movefile.py

index 8a7a2b6a65409869254564ce3ae3a9a10f1a3ecd..f33e67c6288327990629036a313798053f9d3f76 100644 (file)
@@ -224,6 +224,12 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                                        target != os.readlink(dest):
                                        raise
                        lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
+
+                       try:
+                               _os.unlink(src_bytes)
+                       except OSError:
+                               pass
+
                        if sys.hexversion >= 0x3030000:
                                try:
                                        os.utime(dest, ns=(sstat.st_mtime_ns, sstat.st_mtime_ns), follow_symlinks=False)
@@ -277,6 +283,10 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                                        writemsg("!!! %s\n" % (e,), noiselevel=-1)
                                        return None
                                hardlinked = True
+                               try:
+                                       _os.unlink(src_bytes)
+                               except OSError:
+                                       pass
                                break
 
        renamefailed=1