@@ -49,13 +49,10 @@ pub async fn delete(stream_name: Path<String>) -> Result<impl Responder, StreamE
49
49
let stream_name = stream_name. into_inner ( ) ;
50
50
// Error out if stream doesn't exist in memory, or in the case of query node, in storage as well
51
51
if !PARSEABLE . streams . contains ( & stream_name)
52
- && PARSEABLE . options . mode == Mode :: Query
53
- && matches ! (
54
- PARSEABLE
52
+ && ( PARSEABLE . options . mode != Mode :: Query
53
+ || !PARSEABLE
55
54
. create_stream_and_schema_from_storage ( & stream_name)
56
- . await ,
57
- Ok ( true ) | Err ( _)
58
- )
55
+ . await ?)
59
56
{
60
57
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
61
58
}
@@ -133,10 +130,11 @@ pub async fn get_schema(stream_name: Path<String>) -> Result<impl Responder, Str
133
130
let stream_name = stream_name. into_inner ( ) ;
134
131
135
132
// Ensure parseable is aware of stream in distributed mode
136
- if PARSEABLE . options . mode == Mode :: Query
137
- && !PARSEABLE
138
- . create_stream_and_schema_from_storage ( & stream_name)
139
- . await ?
133
+ if !PARSEABLE . streams . contains ( & stream_name)
134
+ && ( PARSEABLE . options . mode != Mode :: Query
135
+ || !PARSEABLE
136
+ . create_stream_and_schema_from_storage ( & stream_name)
137
+ . await ?)
140
138
{
141
139
return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ;
142
140
}
@@ -173,10 +171,11 @@ pub async fn get_retention(stream_name: Path<String>) -> Result<impl Responder,
173
171
// For query mode, if the stream not found in memory map,
174
172
//check if it exists in the storage
175
173
//create stream and schema from storage
176
- if PARSEABLE . options . mode == Mode :: Query
177
- && !PARSEABLE
178
- . create_stream_and_schema_from_storage ( & stream_name)
179
- . await ?
174
+ if !PARSEABLE . streams . contains ( & stream_name)
175
+ && ( PARSEABLE . options . mode != Mode :: Query
176
+ || !PARSEABLE
177
+ . create_stream_and_schema_from_storage ( & stream_name)
178
+ . await ?)
180
179
{
181
180
return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ;
182
181
}
@@ -197,10 +196,11 @@ pub async fn put_retention(
197
196
// For query mode, if the stream not found in memory map,
198
197
//check if it exists in the storage
199
198
//create stream and schema from storage
200
- if PARSEABLE . options . mode == Mode :: Query
201
- && !PARSEABLE
202
- . create_stream_and_schema_from_storage ( & stream_name)
203
- . await ?
199
+ if !PARSEABLE . streams . contains ( & stream_name)
200
+ && ( PARSEABLE . options . mode != Mode :: Query
201
+ || !PARSEABLE
202
+ . create_stream_and_schema_from_storage ( & stream_name)
203
+ . await ?)
204
204
{
205
205
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
206
206
}
@@ -410,10 +410,11 @@ pub async fn put_stream_hot_tier(
410
410
// For query mode, if the stream not found in memory map,
411
411
//check if it exists in the storage
412
412
//create stream and schema from storage
413
- if PARSEABLE . options . mode == Mode :: Query
414
- && !PARSEABLE
415
- . create_stream_and_schema_from_storage ( & stream_name)
416
- . await ?
413
+ if !PARSEABLE . streams . contains ( & stream_name)
414
+ && ( PARSEABLE . options . mode != Mode :: Query
415
+ || !PARSEABLE
416
+ . create_stream_and_schema_from_storage ( & stream_name)
417
+ . await ?)
417
418
{
418
419
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
419
420
}
@@ -486,10 +487,11 @@ pub async fn delete_stream_hot_tier(
486
487
// For query mode, if the stream not found in memory map,
487
488
//check if it exists in the storage
488
489
//create stream and schema from storage
489
- if PARSEABLE . options . mode == Mode :: Query
490
- && !PARSEABLE
491
- . create_stream_and_schema_from_storage ( & stream_name)
492
- . await ?
490
+ if !PARSEABLE . streams . contains ( & stream_name)
491
+ && ( PARSEABLE . options . mode != Mode :: Query
492
+ || !PARSEABLE
493
+ . create_stream_and_schema_from_storage ( & stream_name)
494
+ . await ?)
493
495
{
494
496
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
495
497
}
0 commit comments