From 9a622a750dfbe159332ddf4869ab3e21e467a0fc Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 1 Feb 2024 10:26:29 +0300 Subject: [PATCH] [#970] fstree: Move temporary path handling in a separate function Allow to easier test different implementations. Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/blobstor/fstree/fstree.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index af241bec..3da5568e 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -357,9 +357,12 @@ func (t *FSTree) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, err } size = len(prm.RawData) + return common.PutRes{StorageID: []byte{}}, t.writeData(p, prm.RawData) +} + +func (t *FSTree) writeData(p string, data []byte) error { tmpPath := p + "#" + strconv.FormatUint(t.suffix.Add(1), 10) - err = t.writeAndRename(tmpPath, p, prm.RawData) - return common.PutRes{StorageID: []byte{}}, err + return t.writeAndRename(tmpPath, p, data) } // writeAndRename opens tmpPath exclusively, writes data to it and renames it to p.