aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/cas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-05-02 17:01:09 +0200
committerGitHub Enterprise <[email protected]>2024-05-02 17:01:09 +0200
commit375fa71cb816acb25bd2eaf24ef5cc292a1f2c36 (patch)
tree7d8e20b99bd65af37f75cb95f18c0c0001e58dcd /src/zenstore/cas.cpp
parentbatch cache put (#67) (diff)
downloadzen-375fa71cb816acb25bd2eaf24ef5cc292a1f2c36.tar.xz
zen-375fa71cb816acb25bd2eaf24ef5cc292a1f2c36.zip
use write and move in place for safer writing of files (#70)
* use write and move in place for safer writing of files
Diffstat (limited to 'src/zenstore/cas.cpp')
-rw-r--r--src/zenstore/cas.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/zenstore/cas.cpp b/src/zenstore/cas.cpp
index 67790e2c6..f300c08e3 100644
--- a/src/zenstore/cas.cpp
+++ b/src/zenstore/cas.cpp
@@ -220,19 +220,7 @@ CasImpl::UpdateManifest()
ZEN_TRACE("Writing new manifest to '{}'", ManifestPath);
- TemporaryFile Marker;
- std::error_code Ec;
- Marker.CreateTemporary(ManifestPath.parent_path(), Ec);
- if (Ec)
- {
- throw std::system_error(Ec, fmt::format("Failed to create temp file for cas manifest at '{}'", ManifestPath));
- }
- Marker.Write(m_ManifestObject.GetBuffer(), 0);
- Marker.MoveTemporaryIntoPlace(ManifestPath, Ec);
- if (Ec)
- {
- throw std::system_error(Ec, fmt::format("Failed to move temp file '{}' to '{}'", Marker.GetPath(), ManifestPath));
- }
+ TemporaryFile::SafeWriteFile(ManifestPath, m_ManifestObject.GetBuffer().GetView());
}
CasStore::InsertResult