aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-22 03:59:15 -1000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-23 17:47:26 +0100
commitc5b8a2fce98c362ea77d74a8bc472d01b739a98a (patch)
tree6d62464962ad372ad9f7a5b806c73492532434b3
parente3da0ecbd282da060b52a4bcf3ed36497295fde0 (diff)
downloadbitbake-contrib-c5b8a2fce98c362ea77d74a8bc472d01b739a98a.tar.gz
fetch2/git: Use os.rename instead of mv
os.rename will overwrite the destination file if present so we can use this instead of the process call overhead. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit b3cccaa6a896c41d8c9be5eebc327f726542d16b) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/git.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 81335c117..000aee190 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -412,14 +412,14 @@ class Git(FetchMethod):
# Create as a temp file and move atomically into position to avoid races
@contextmanager
- def create_atomic(filename, d):
+ def create_atomic(filename):
fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename))
try:
yield tfile
umask = os.umask(0o666)
os.umask(umask)
os.chmod(tfile, (0o666 & ~umask))
- runfetchcmd("mv %s %s" % (tfile, filename), d)
+ os.rename(tfile, filename)
finally:
os.close(fd)
@@ -433,7 +433,7 @@ class Git(FetchMethod):
self.clone_shallow_local(ud, shallowclone, d)
logger.info("Creating tarball of git repository")
- with create_atomic(ud.fullshallow, d) as tfile:
+ with create_atomic(ud.fullshallow) as tfile:
runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone)
runfetchcmd("touch %s.done" % ud.fullshallow, d)
finally:
@@ -443,7 +443,7 @@ class Git(FetchMethod):
os.unlink(ud.fullmirror)
logger.info("Creating tarball of git repository")
- with create_atomic(ud.fullmirror, d) as tfile:
+ with create_atomic(ud.fullmirror) as tfile:
runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir)
runfetchcmd("touch %s.done" % ud.fullmirror, d)