Skip to content

Commit b8b0b18

Browse files
index storage path in env (#1274)
* index storage path in env * method to create index dir * add todo
1 parent 26e700d commit b8b0b18

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/cli.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ pub struct Options {
225225
)]
226226
pub hot_tier_storage_path: Option<PathBuf>,
227227

228+
//TODO: remove this when smart cache is implemented
229+
#[arg(
230+
long = "index-storage-path",
231+
env = "P_INDEX_DIR",
232+
value_parser = validation::canonicalize_path,
233+
help = "Local path on this indexer used for indexing"
234+
)]
235+
pub index_storage_path: Option<PathBuf>,
236+
228237
#[arg(
229238
long,
230239
env = "P_MAX_DISK_USAGE_PERCENT",
@@ -419,6 +428,17 @@ impl Options {
419428
&self.local_staging_path
420429
}
421430

431+
/// Path to index directory, ensures that it exists or returns the PathBuf
432+
pub fn index_dir(&self) -> Option<&PathBuf> {
433+
if let Some(path) = &self.index_storage_path {
434+
fs::create_dir_all(path)
435+
.expect("Should be able to create index directory if it doesn't exist");
436+
Some(path)
437+
} else {
438+
None
439+
}
440+
}
441+
422442
/// TODO: refactor and document
423443
pub fn get_url(&self, mode: Mode) -> Url {
424444
let (endpoint, env_var) = match mode {

0 commit comments

Comments
 (0)