Skip to content

Commit

Permalink
Fixed issues with CLI plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenstott committed Aug 30, 2024
1 parent 608cd25 commit e3e440d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 6 additions & 4 deletions crates/calcite-schema/src/list_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use tracing::debug;
#[tracing::instrument(skip())]
pub fn list_files_in_directory(dir: &Path) -> Result<Vec<String>, Box<dyn std::error::Error>> {
debug!("Inspecting directory: {}", dir.display());
let attempts = 1;
let seconds = 1;

for attempt in 0..3 {
for attempt in 0..attempts {
let mut file_list = Vec::new();
for entry in std::fs::read_dir(dir)? {
let entry = entry?;
Expand All @@ -28,9 +30,9 @@ pub fn list_files_in_directory(dir: &Path) -> Result<Vec<String>, Box<dyn std::e
}

// if no files were found, sleep for 5 seconds before trying again
if attempt < 2 {
eprintln!("No files found on attempt {}. Retrying after 5 seconds...", attempt + 1);
std::thread::sleep(std::time::Duration::from_secs(5));
if attempt < attempts - 1 {
eprintln!("No files found on attempt {}. Retrying after {} seconds...", attempt + 1, seconds);
std::thread::sleep(std::time::Duration::from_secs(seconds));
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
//! The CLI can do a few things. This provides a central point where those things are routed and
//! then done, making it easier to test this crate deterministically.
use std::path::{Path, PathBuf};
use std::path::{PathBuf};

use clap::Subcommand;
use include_dir::{DirEntry, include_dir};
use include_dir::Dir;
use tokio::fs;
use tracing::debug;

use ndc_calcite_schema::configuration::{has_configuration, introspect, parse_configuration, ParsedConfiguration, upgrade_to_latest_version, write_parsed_configuration};
use ndc_calcite_schema::environment::Environment;
Expand Down Expand Up @@ -96,7 +95,7 @@ async fn initialize(with_metadata: bool, context: &Context<impl Environment>) ->
match entry {
DirEntry::Dir(dir) => {
let path = dir.path();
fs::create_dir(path).await?
fs::create_dir((config_path).join(path)).await?
}
DirEntry::File(file) => {
let path = file.path();
Expand Down
2 changes: 1 addition & 1 deletion crates/connectors/ndc-calcite/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn select(
field_statements.push(field_statement);
}
}
Field::Relationship { relationship, arguments, .. } => {
Field::Relationship { relationship, .. } => {
if supports_json_object {
field_statements.push( format!("'{}', 1", key));
} else {
Expand Down

0 comments on commit e3e440d

Please sign in to comment.