diff options
author | Jürg Billeter <j@bitron.ch> | 2019-05-23 16:00:29 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-05-23 16:20:37 +0200 |
commit | 45d3cf7f048571abc8e45ed7f14e27852042eca5 (patch) | |
tree | 9095a67adb0db846e93fd25e67064db74e524bc4 | |
parent | fc5e3c33e2e36cd8f77d2897f701240356577879 (diff) | |
download | buildstream-45d3cf7f048571abc8e45ed7f14e27852042eca5.tar.gz |
casserver.py: Create artifact proto file atomicallyjuerg/atomic-artifact
-rw-r--r-- | src/buildstream/_cas/casserver.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/buildstream/_cas/casserver.py b/src/buildstream/_cas/casserver.py index c08a4d577..e3a69c77f 100644 --- a/src/buildstream/_cas/casserver.py +++ b/src/buildstream/_cas/casserver.py @@ -37,6 +37,7 @@ from .._protos.google.rpc import code_pb2 from .._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc, \ artifact_pb2, artifact_pb2_grpc +from .. import utils from .._exceptions import CASError from .cascache import CASCache @@ -474,7 +475,7 @@ class _ArtifactServicer(artifact_pb2_grpc.ArtifactServiceServicer): # Add the artifact proto to the cas artifact_path = os.path.join(self.artifactdir, request.cache_key) os.makedirs(os.path.dirname(artifact_path), exist_ok=True) - with open(artifact_path, 'wb') as f: + with utils.save_file_atomic(artifact_path, mode='wb') as f: f.write(artifact.SerializeToString()) return artifact |