movefile: fix abs symlink adjustment, bug #416431
authorZac Medico <zmedico@gentoo.org>
Thu, 17 May 2012 20:20:48 +0000 (13:20 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 17 May 2012 20:20:48 +0000 (13:20 -0700)
pym/portage/util/movefile.py

index 5ffd16bf03a7f4c2a58305045c727976e6f44696..10577b5659d671558b45d4f8da98b92257a701f7 100644 (file)
@@ -141,9 +141,9 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
        if stat.S_ISLNK(sstat[stat.ST_MODE]):
                try:
                        target=os.readlink(src)
-                       if mysettings and mysettings["D"]:
-                               if target.find(mysettings["D"])==0:
-                                       target=target[len(mysettings["D"]):]
+                       if mysettings and "D" in mysettings and \
+                               target.startswith(mysettings["D"]):
+                               target = target[len(mysettings["D"])-1:]
                        if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]):
                                os.unlink(dest)
                        try: