Skip to content

Commit

Permalink
NBSNEBIUS-36: use tmp file for endpoint storage (#133)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Rigachnyi <[email protected]>
  • Loading branch information
2 people authored and qkrorlqr committed Jan 17, 2024
1 parent b5809e5 commit 9410571
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cloud/storage/core/libs/keyring/endpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <util/string/strip.h>
#include <util/system/file.h>
#include <util/system/mutex.h>
#include <util/system/tempfile.h>

namespace NCloud {

Expand Down Expand Up @@ -165,9 +166,10 @@ class TFileStorage final
TGuard guard(Mutex);

auto id = GetFreeId();
auto filepath = DirPath.Child(ToString(id));
TFile file(filepath, EOpenModeFlag::CreateAlways);
TFileOutput(file).Write(endpointSpec);
TFsPath tmpFilePath(MakeTempName(nullptr, "endpoint"));
TFileOutput(tmpFilePath).Write(endpointSpec);
tmpFilePath.ForceRenameTo(DirPath.Child(ToString(id)));

return id;
}

Expand Down

0 comments on commit 9410571

Please sign in to comment.