summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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