<div dir="ltr"><div><div>Hi Richard,<br><br></div>I adjusted commit message and function description. <span class="gmail-short_text" id="gmail-result_box" lang="en"><span>but I do not</span> <span>agree with</span> <span class="gmail-">proposed</span><br>function <span class="gmail-">name</span></span> `create_valid_symlink`, becasue link creation could fail - so I left `try_symlink`<br></div>to point this behaviour.<br><div><br></div><div>Regards,<br></div><div>Roman<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-23 10:45 GMT+03:00 Roman Savchenko <span dir="ltr">&lt;<a href="mailto:gmstima@gmail.com" target="_blank">gmstima@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Roman Savchenko &lt;<a href="mailto:roman.savchenko@attocapital.com">roman.savchenko@attocapital.<wbr>com</a>&gt;<br>
<br>
When making new symlink in case when link name does not exist<br>
possible broken symlink behaviour should be taken into account.<br>
<span class=""><br>
Signed-off-by: Roman Savchenko &lt;<a href="mailto:gmstima@gmail.com">gmstima@gmail.com</a>&gt;<br>
---<br>
 bitbake/lib/bb/fetch2/__init__<wbr>.py | 21 +++++++++++++--------<br>
 1 file changed, 13 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/bitbake/lib/bb/fetch2/__<wbr>init__.py b/bitbake/lib/bb/fetch2/__<wbr>init__.py<br>
</span>index 6ef0c6f..d8a3b96 100644<br>
<span class="">--- a/bitbake/lib/bb/fetch2/__<wbr>init__.py<br>
+++ b/bitbake/lib/bb/fetch2/__<wbr>init__.py<br>
@@ -925,6 +925,17 @@ def rename_bad_checksum(ud, suffix):<br>
     bb.utils.movefile(ud.<wbr>localpath, new_localpath)<br>
<br>
<br>
+def try_symlink(source, link_name):<br>
+    &quot;&quot;&quot;<br>
+    Tries to make link to passed source if link name does not<br>
</span>+    exist or it is the invalid symlink.<br>
<div class="HOEnZb"><div class="h5">+    &quot;&quot;&quot;<br>
+    if not os.path.exists(link_name):<br>
+        if os.path.islink(link_name):<br>
+            os.unlink(link_name)<br>
+<br>
+        os.symlink(source, link_name)<br>
+<br>
 def try_mirror_url(fetch, origud, ud, ld, check = False):<br>
     # Return of None or a value means we&#39;re finished<br>
     # False means try another url<br>
@@ -962,20 +973,14 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):<br>
                 bb.utils.mkdirhier(os.path.<wbr>dirname(ud.donestamp))<br>
                 open(ud.donestamp, &#39;w&#39;).close()<br>
             dest = os.path.join(dldir, os.path.basename(ud.localpath)<wbr>)<br>
-            if not os.path.exists(dest):<br>
-                os.symlink(ud.localpath, dest)<br>
+            try_symlink(ud.localpath, dest)<br>
             if not verify_donestamp(origud, ld) or origud.method.need_update(<wbr>origud, ld):<br>
                 origud.method.download(origud, ld)<br>
                 if hasattr(origud.method,&quot;build_<wbr>mirror_data&quot;):<br>
                     origud.method.build_mirror_<wbr>data(origud, ld)<br>
             return origud.localpath<br>
         # Otherwise the result is a local file:// and we symlink to it<br>
-        if not os.path.exists(origud.<wbr>localpath):<br>
-            if os.path.islink(origud.<wbr>localpath):<br>
-                # Broken symbolic link<br>
-                os.unlink(origud.localpath)<br>
-<br>
-            os.symlink(ud.localpath, origud.localpath)<br>
+        try_symlink(ud.localpath, origud.localpath)<br>
         update_stamp(origud, ld)<br>
         return ud.localpath<br>
<br>
--<br>
2.7.4<br>
<br>
</div></div></blockquote></div><br></div>