Skip to content

Commit

Permalink
Don't require absolute paths in sqlite runtime config resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
  • Loading branch information
rylev committed Aug 19, 2024
1 parent 12cc792 commit 3cafa2a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 1 addition & 12 deletions crates/factor-sqlite/src/runtime_config/spin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,10 @@ impl RuntimeConfigResolver {
/// This takes as arguments:
/// * the directory to use as the default location for SQLite databases.
/// Usually this will be the path to the `.spin` state directory.
/// * the *absolute* path to the directory from which relative paths to
/// * the path to the directory from which relative paths to
/// local SQLite databases are resolved. (this should most likely be the
/// path to the runtime-config file or the current working dir).
///
/// Panics if either `default_database_dir` or `local_database_dir` are not
/// absolute paths.
pub fn new(default_database_dir: PathBuf, local_database_dir: PathBuf) -> Self {
assert!(
default_database_dir.is_absolute(),
"default_database_dir must be an absolute path"
);
assert!(
local_database_dir.is_absolute(),
"local_database_dir must be an absolute path"
);
Self {
default_database_dir,
local_database_dir,
Expand Down
2 changes: 0 additions & 2 deletions crates/runtime-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ fn sqlite_config_resolver(
state_dir: Option<&str>,
) -> anyhow::Result<sqlite::RuntimeConfigResolver> {
let default_database_dir = PathBuf::from(state_dir.unwrap_or(DEFAULT_STATE_DIR));
let default_database_dir = std::path::absolute(default_database_dir)
.context("failed to make default database directory absolute")?;
let local_database_dir =
std::env::current_dir().context("failed to get current working directory")?;
Ok(sqlite::RuntimeConfigResolver::new(
Expand Down

0 comments on commit 3cafa2a

Please sign in to comment.