OpenJDK / graal / graal-jvmci-8
changeset 8180:0934903d28f3
use shutil.move to make concurrent updating/replacement of graal.jar atomic
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 08 Mar 2013 15:55:37 +0100 |
parents | 80a825206cbc |
children | 989e0582a30f |
files | mx/commands.py mxtool/mx.py |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mx/commands.py Fri Mar 08 14:33:33 2013 +0100 +++ b/mx/commands.py Fri Mar 08 15:55:37 2013 +0100 @@ -385,7 +385,10 @@ for e in os.listdir(jdks): jreLibDir = join(jdks, e, 'jre', 'lib') if exists(jreLibDir): - shutil.copyfile(graalJar, join(jreLibDir, 'graal.jar')) + # do a copy and then a move to get atomic updating (on Unix) of graal.jar in the JRE + _, tmp = tempfile.mkstemp(suffix='', prefix='graal.jar', dir=jreLibDir) + shutil.copyfile(graalJar, tmp) + shutil.move(tmp, join(jreLibDir, 'graal.jar')) # run a command in the windows SDK Debug Shell def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}):
--- a/mxtool/mx.py Fri Mar 08 14:33:33 2013 +0100 +++ b/mxtool/mx.py Fri Mar 08 15:55:37 2013 +0100 @@ -1651,7 +1651,8 @@ if name.startswith('@'): dname = name[1:] d = distribution(dname) - zf = zipfile.ZipFile(d.path, 'w') + _, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path), dir=dirname(d.path)) + zf = zipfile.ZipFile(tmp, 'w') for p in sorted_deps(d.deps): outputDir = p.output_dir() for root, _, files in os.walk(outputDir): @@ -1660,19 +1661,24 @@ arcname = join(relpath, f).replace(os.sep, '/') zf.write(join(root, f), arcname) zf.close() + # Atomic on Unix + shutil.move(tmp, d.path) + #print time.time(), 'move:', tmp, '->', d.path d.notify_updated() else: p = project(name) outputDir = p.output_dir() - jar = join(p.dir, p.name + '.jar') - zf = zipfile.ZipFile(jar, 'w') + _, tmp = tempfile.mkstemp(suffix='', prefix=p.name, dir=p.dir) + zf = zipfile.ZipFile(tmp, 'w') for root, _, files in os.walk(outputDir): for f in files: relpath = root[len(outputDir) + 1:] arcname = join(relpath, f).replace(os.sep, '/') zf.write(join(root, f), arcname) zf.close() + # Atomic on Unix + shutil.move(tmp, join(p.dir, p.name + '.jar')) def canonicalizeprojects(args): """process all project files to canonicalize the dependencies