Skip to content

Commit ba18bc9

Browse files
committed
fix: deepsource and coderabbit
1 parent 22fbbef commit ba18bc9

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/parseable/staging/writer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ use crate::{
4242

4343
use super::StagingError;
4444

45+
const DISK_WRITE_BATCH_MAX_AGE_SECS_VAR: &str = "DISK_WRITE_BATCH_MAX_AGE_SECS";
4546
static DISK_WRITE_BATCH_MAX_AGE_SECS: Lazy<i64> = Lazy::new(|| {
46-
if let Ok(var) = std::env::var("P_DISK_WRITE_BATCH_MAX_AGE_SECS")
47+
if let Ok(var) = std::env::var(DISK_WRITE_BATCH_MAX_AGE_SECS_VAR)
4748
&& let Ok(var) = var.parse::<i64>()
4849
{
4950
var

src/parseable/streams.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ use super::{
7070
staging::{StagingError, reader::MergedReverseRecordReader, writer::Writer},
7171
};
7272

73+
const DISK_WRITE_BATCH_ROWS_VAR: &str = "DISK_WRITE_BATCH_ROWS";
7374
static DISK_WRITE_BATCH_ROWS: Lazy<usize> = Lazy::new(|| {
74-
if let Ok(var) = std::env::var("P_DISK_WRITE_BATCH_ROWS")
75+
if let Ok(var) = std::env::var(DISK_WRITE_BATCH_ROWS_VAR)
7576
&& let Ok(var) = var.parse::<usize>()
7677
{
7778
var
@@ -449,17 +450,15 @@ impl Stream {
449450
}
450451

451452
pub fn get_schemas_if_present(&self) -> Result<Vec<Schema>, StagingError> {
452-
let Ok(dir) = self.data_path.read_dir() else {
453-
return Ok(vec![]);
454-
};
453+
let dir = self.data_path.read_dir()?;
455454

456455
let mut schemas: Vec<Schema> = Vec::new();
457456

458457
for file in dir.flatten() {
459458
if let Some(ext) = file.path().extension()
460459
&& ext.eq("schema")
461460
{
462-
let file = File::open(file.path()).expect("Schema File should exist");
461+
let file = File::open(file.path())?;
463462

464463
schemas.push(serde_json::from_reader(file)?);
465464
}
@@ -524,11 +523,10 @@ impl Stream {
524523
fs::create_dir_all(&self.data_path)?;
525524

526525
// need to add something before .schema to make the file have an extension of type `schema`
527-
let file_name = self
528-
.ingestor_id
529-
.as_ref()
530-
.map(|id| format!(".ingestor.{id}.schema"))
531-
.unwrap_or_else(|| ".schema".to_owned());
526+
let file_name = self.ingestor_id.as_ref().map_or_else(
527+
|| ".schema".to_owned(),
528+
|id| format!(".ingestor.{id}.schema"),
529+
);
532530
let path = RelativePathBuf::from_iter([file_name]).to_path(&self.data_path);
533531
let tmp_path = path.with_extension("schema.tmp");
534532

0 commit comments

Comments
 (0)