[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5458/8267] bitbake: fetch2: Do not fail to create symbolic links if they already exist
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 5458/8267] bitbake: fetch2: Do not fail to create symbolic links if they already exist
- Date: Sun, 17 Dec 2017 03:28:06 +0000 (UTC)
commit 4077dcb565153340bb01f1794db6a7ff4415ca5d
Author: Peter Kjellerstedt <peter kjellerstedt axis com>
Date: Fri Mar 31 16:59:56 2017 +0200
bitbake: fetch2: Do not fail to create symbolic links if they already exist
When the fetcher retrieves file:// URLs, there is no lock file being
used. This means that in case two separate tasks (typically from two
concurrent invocations of bitbake) want to download the same file://
URL at the same time, there is a very small chance that they also end
up wanting to create a symbolic link to the file at the same time.
This would previously lead to one of the tasks failing as the other
task would have created the link.
(Bitbake rev: 58a03531c8183b165bb7dcad86d8559c92bc150d)
Signed-off-by: Peter Kjellerstedt <pkj axis com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
bitbake/lib/bb/fetch2/__init__.py | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index ea72025..136fc29 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -983,7 +983,14 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
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)
+ # In case this is executing without any file locks held (as is
+ # the case for file:// URLs), two tasks may end up here at the
+ # same time, in which case we do not want the second task to
+ # fail when the link has already been created by the first task.
+ try:
+ os.symlink(ud.localpath, dest)
+ except FileExistsError:
+ pass
if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld):
origud.method.download(origud, ld)
if hasattr(origud.method,"build_mirror_data"):
@@ -995,7 +1002,11 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
# Broken symbolic link
os.unlink(origud.localpath)
- os.symlink(ud.localpath, origud.localpath)
+ # As per above, in case two tasks end up here simultaneously.
+ try:
+ os.symlink(ud.localpath, origud.localpath)
+ except FileExistsError:
+ pass
update_stamp(origud, ld)
return ud.localpath
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]