Skip to content

Commit

Permalink
Switched to using .taf directory instead of .stelae
Browse files Browse the repository at this point in the history
  • Loading branch information
BojanG99 committed Dec 2, 2024
1 parent ce3142d commit 28c0113
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Stelae is a system for distributing, preserving, and authenticating laws.
- `format`: Format code
- `lint`: Format code and run strict clippy
- `test`: Run all tests
- Install nextest with command `cargo install cargo-nextest`
- On windows, especially, you may wish to run just through the nu shell, which can be done by calling all commands with the `--shell` command, e.g. `just --shell nu lint`.

## Logging
Expand Down
2 changes: 1 addition & 1 deletion src/db/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
/// Connections can fail if the database is not running, or if the database URL is invalid.
pub async fn connect(archive_path: &Path) -> anyhow::Result<DatabaseConnection> {
let db_url = env::var("DATABASE_URL").unwrap_or_else(|_| {
let sqlite_db_path = &archive_path.join(PathBuf::from(".stelae/db.sqlite3"));
let sqlite_db_path = &archive_path.join(PathBuf::from(".taf/db.sqlite3"));
format!("sqlite:///{}?mode=rwc", sqlite_db_path.to_string_lossy())
});
let connection = DatabaseConnection::connect(&db_url).await?;
Expand Down
2 changes: 1 addition & 1 deletion src/history/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub async fn insert(raw_archive_path: &str, archive_path: PathBuf) -> Result<(),
Err(err) => {
tracing::error!(
"error: could not connect to database.
Confirm that `db.sqlite3` exists in `.stelae` dir or that DATABASE_URL env var is set correctly."
Confirm that `db.sqlite3` exists in `.taf` dir or that DATABASE_URL env var is set correctly."
);
tracing::error!("Error: {err:?}");
return Err(CliError::DatabaseConnectionError);
Expand Down
6 changes: 3 additions & 3 deletions src/stelae/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub struct Archive {
impl Archive {
/// Get an archive's config object.
/// # Errors
/// Will error if unable to find or parse config file at `.stelae/config.toml`
/// Will error if unable to find or parse config file at `.taf/config.toml`
pub fn get_config(&self) -> anyhow::Result<Config> {
let config_path = &self.path.join(PathBuf::from(".stelae/config.toml"));
let config_path = &self.path.join(PathBuf::from(".taf/config.toml"));
let config_str = read_to_string(config_path)?;
let conf: Config = toml::from_str(&config_str)?;
Ok(conf)
Expand Down Expand Up @@ -180,7 +180,7 @@ pub fn init(
headers: Option<Headers>,
) -> anyhow::Result<Box<Archive>> {
raise_error_if_in_existing_archive(&path)?;
let stelae_dir = path.join(PathBuf::from("./.stelae"));
let stelae_dir = path.join(PathBuf::from("./.taf"));
create_dir_all(&stelae_dir)?;
let config_path = stelae_dir.join(PathBuf::from("./config.toml"));
let conf = Config {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
pub fn find_archive_path(path: &Path) -> anyhow::Result<PathBuf> {
let abs_path = fix_unc_path(&path.canonicalize()?);
for working_path in abs_path.ancestors() {
if working_path.join(".stelae").exists() {
if working_path.join(".taf").exists() {
return Ok(working_path.to_owned());
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/utils/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ enum Subcommands {

/// Place to initialize tracing
///
/// We create `debug` and `error` log files in `.stelae` dir.
/// We create `debug` and `error` log files in `.taf` dir.
/// `debug` log file contains all logs, `error` log file contains only `warn` and `error`
/// NOTE: once `https://github.com/tokio-rs/tracing/pull/2497` is merged,
/// update `init_tracing` to rotate log files based on size.
#[allow(clippy::expect_used)]
fn init_tracing(archive_path: &Path) {
let stelae_dir = archive_path.join(PathBuf::from("./.stelae"));
let taf_dir = archive_path.join(PathBuf::from("./.taf"));

let debug_file_appender =
rolling::never(&stelae_dir, "stelae-debug.log").with_max_level(Level::DEBUG);
rolling::never(&taf_dir, "stelae-debug.log").with_max_level(Level::DEBUG);
let error_file_appender =
rolling::never(&stelae_dir, "stelae-error.log").with_max_level(Level::WARN);
rolling::never(&taf_dir, "stelae-error.log").with_max_level(Level::WARN);

let mut debug_layer = fmt::layer().with_writer(debug_file_appender);
let mut error_layer = fmt::layer().with_writer(error_file_appender);
Expand Down Expand Up @@ -126,7 +126,7 @@ pub fn run() {
let archive_path_wd = Path::new(&cli.archive_path);
let Ok(archive_path) = find_archive_path(archive_path_wd) else {
tracing::error!(
"error: could not find `.stelae` folder in `{}` or any parent directory",
"error: could not find `.taf` folder in `{}` or any parent directory",
&cli.archive_path
);
process::exit(1);
Expand Down
File renamed without changes.

0 comments on commit 28c0113

Please sign in to comment.