Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/app-lib/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ MODRINTH_API_URL_V3=http://127.0.0.1:8000/v3/
MODRINTH_SOCKET_URL=ws://127.0.0.1:8000/
MODRINTH_LAUNCHER_META_URL=https://launcher-meta.modrinth.com/

# Theseus config directory for development
# THESEUS_CONFIG_DIR=

# SQLite database file used by sqlx for type checking. Uncomment this to a valid path
# in your system and run `cargo sqlx database setup` to generate an empty database that
# can be used for developing the app DB schema
Expand Down
16 changes: 9 additions & 7 deletions packages/app-lib/src/state/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ impl DirectoryInfo {
// Get the settings directory
// init() is not needed for this function
pub fn initial_settings_dir_path(app_identifier: &str) -> Option<PathBuf> {
Self::env_path("THESEUS_CONFIG_DIR")
// Use option_env! to read compile-time env var set by build.rs from .env file
option_env!("THESEUS_CONFIG_DIR")
.and_then(|p| {
if p.is_empty() {
None
} else {
Some(PathBuf::from(p))
}
})
.or_else(|| Some(dirs::data_dir()?.join(app_identifier)))
}

Expand Down Expand Up @@ -184,12 +192,6 @@ impl DirectoryInfo {
self.config_dir.join(CACHES_FOLDER_NAME)
}

/// Get path from environment variable
#[inline]
fn env_path(name: &str) -> Option<PathBuf> {
std::env::var_os(name).map(PathBuf::from)
}

#[tracing::instrument(skip(settings, exec, io_semaphore))]
pub async fn move_launcher_directory<'a, E>(
settings: &mut Settings,
Expand Down