diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index a51acbbc66..08ec75ace9 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -239,16 +239,17 @@ func (t *FSTree) Put(prm common.PutPrm) (common.PutRes, error) { prm.RawData = t.Compress(prm.RawData) } - err := t.writeFile(p, prm.RawData) + tmpPath := p + "#" + err := t.writeFile(tmpPath, prm.RawData) if err != nil { var pe *fs.PathError if errors.As(err, &pe) && pe.Err == syscall.ENOSPC { err = common.ErrNoSpace - _ = os.RemoveAll(p) + _ = os.RemoveAll(tmpPath) } } - return common.PutRes{StorageID: []byte{}}, err + return common.PutRes{StorageID: []byte{}}, os.Rename(tmpPath, p) } func (t *FSTree) writeFlags() int {