Commit 48fdf633 authored by Vadim Shtayura's avatar Vadim Shtayura Committed by Commit Bot

Potential fix for the failing Fuchsia SDK update hook.

It appears using external process to write to a file we hold an open handle for
isn't 100% reliable (I suspect we need an fsync somewhere or maybe gsutil is
doing 'mv' somewhere and writes to another inode, or something like that).

Reopening the file before reading from it fixes the bug, at least locally for
me.

R=scottmg@chromium.org, kbr@chromium.org
BUG=795330

Change-Id: I498540ec62439c02243b84a5577c4b225ba5e1f3
Reviewed-on: https://chromium-review.googlesource.com/830257
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524439}
parent bfe58719
......@@ -46,14 +46,19 @@ def main():
if os.path.isdir(output_dir):
shutil.rmtree(output_dir)
bucket = 'gs://fuchsia/sdk/linux-amd64/'
with tempfile.NamedTemporaryFile() as f:
fd, tmp = tempfile.mkstemp()
os.close(fd)
try:
bucket = 'gs://fuchsia/sdk/linux-amd64/'
cmd = [os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py'),
'cp', bucket + sdk_hash, f.name]
'cp', bucket + sdk_hash, tmp]
subprocess.check_call(cmd)
f.seek(0)
EnsureDirExists(output_dir)
tarfile.open(mode='r:gz', fileobj=f).extractall(path=output_dir)
with open(tmp, 'rb') as f:
EnsureDirExists(output_dir)
tarfile.open(mode='r:gz', fileobj=f).extractall(path=output_dir)
finally:
os.remove(tmp)
with open(hash_filename, 'w') as f:
f.write(sdk_hash)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment