refactor: move check to first step of function (#14640)

This commit is contained in:
Marko 2023-01-16 18:15:57 +01:00 committed by GitHub
parent 6887e1db71
commit 79b82c0c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,