From 79b82c0c12e5ee09d02d89347e062cc7914d1d18 Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 16 Jan 2023 18:15:57 +0100 Subject: [PATCH] refactor: move check to first step of function (#14640) --- store/streaming/file/service.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/store/streaming/file/service.go b/store/streaming/file/service.go index 9e5928ac96..1b8ace3f7a 100644 --- a/store/streaming/file/service.go +++ b/store/streaming/file/service.go @@ -51,6 +51,13 @@ func NewStreamingService( logger log.Logger, outputMetadata, stopNodeOnErr, fsync bool, ) (*StreamingService, error) { + // Check that the writeDir exists and is writable so that we can catch the + // error here at initialization. If it is not we don't open a dstFile until we + // receive our first ABCI message. + if err := isDirWriteable(writeDir); err != nil { + return nil, err + } + // sort storeKeys for deterministic output sort.SliceStable(storeKeys, func(i, j int) bool { return storeKeys[i].Name() < storeKeys[j].Name() @@ -62,13 +69,6 @@ func NewStreamingService( listeners[i] = types.NewMemoryListener(key) } - // Check that the writeDir exists and is writable so that we can catch the - // error here at initialization. If it is not we don't open a dstFile until we - // receive our first ABCI message. - if err := isDirWriteable(writeDir); err != nil { - return nil, err - } - return &StreamingService{ storeListeners: listeners, filePrefix: filePrefix,