Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/bb/fetch2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,13 @@ def rename_bad_checksum(ud, suffix):
bb.warn("Renaming %s to %s" % (ud.localpath, new_localpath))
bb.utils.movefile(ud.localpath, new_localpath)

def safe_symlink(source, link_name):
if not os.path.exists(link_name):
if os.path.islink(link_name):
os.unlink(link_name)

os.symlink(source, link_name)
return

def try_mirror_url(origud, ud, ld, check = False):
# Return of None or a value means we're finished
Expand Down Expand Up @@ -821,21 +828,18 @@ def try_mirror_url(origud, ud, ld, check = False):
and os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
bb.utils.mkdirhier(os.path.dirname(ud.donestamp))
open(ud.donestamp, 'w').close()
dest = os.path.join(dldir, os.path.basename(ud.localpath))
if not os.path.exists(dest):
os.symlink(ud.localpath, dest)
dest = os.path.join(dldir, os.path.basename(ud.localpath))
safe_symlink(ud.localpath, dest)

if not os.path.exists(origud.donestamp) or origud.method.need_update(origud, ld):
origud.method.download(origud, ld)
if hasattr(origud.method,"build_mirror_data"):
origud.method.build_mirror_data(origud, ld)
return ud.localpath

# Otherwise the result is a local file:// and we symlink to it
if not os.path.exists(origud.localpath):
if os.path.islink(origud.localpath):
# Broken symbolic link
os.unlink(origud.localpath)
safe_symlink(ud.localpath, origud.localpath)

os.symlink(ud.localpath, origud.localpath)
update_stamp(origud, ld)
return ud.localpath

Expand Down