summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-05-23 16:00:29 +0200
committerJürg Billeter <j@bitron.ch>2019-05-23 16:20:37 +0200
commit45d3cf7f048571abc8e45ed7f14e27852042eca5 (patch)
tree9095a67adb0db846e93fd25e67064db74e524bc4
parentfc5e3c33e2e36cd8f77d2897f701240356577879 (diff)
downloadbuildstream-juerg/atomic-artifact.tar.gz
casserver.py: Create artifact proto file atomicallyjuerg/atomic-artifact
-rw-r--r--src/buildstream/_cas/casserver.py3
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