Keep runtime files inside application support
This commit is contained in:
40
src/app.rs
40
src/app.rs
@@ -2453,7 +2453,7 @@ fn export_markdown(title: &str, conversation: &[ChatMessage]) -> String {
|
||||
output
|
||||
}
|
||||
|
||||
fn application_support_path() -> PathBuf {
|
||||
pub(crate) fn application_support_path() -> PathBuf {
|
||||
std::env::var_os("HOME")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
@@ -2462,10 +2462,14 @@ fn application_support_path() -> PathBuf {
|
||||
.join(APP_ID)
|
||||
}
|
||||
|
||||
fn models_path() -> PathBuf {
|
||||
pub(crate) fn models_path() -> PathBuf {
|
||||
application_support_path().join("models")
|
||||
}
|
||||
|
||||
pub(crate) fn browser_profile_path() -> PathBuf {
|
||||
application_support_path().join("browser")
|
||||
}
|
||||
|
||||
/// The settings file, beside the project database.
|
||||
pub(crate) fn config_path() -> PathBuf {
|
||||
application_support_path().join("config.yaml")
|
||||
@@ -2911,4 +2915,36 @@ mod tests {
|
||||
);
|
||||
assert!(!exported.contains("private"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn owned_runtime_paths_stay_in_application_support() {
|
||||
let root = application_support_path();
|
||||
assert!(models_path().starts_with(&root));
|
||||
assert!(browser_profile_path().starts_with(&root));
|
||||
assert!(config_path().starts_with(&root));
|
||||
assert!(kv_cache_path().starts_with(&root));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_does_not_depend_on_a_sibling_ds4_checkout() {
|
||||
fn scan(path: &Path, forbidden: &str) {
|
||||
if path.is_dir() {
|
||||
for entry in fs::read_dir(path).unwrap() {
|
||||
scan(&entry.unwrap().path(), forbidden);
|
||||
}
|
||||
} else if let Ok(source) = fs::read_to_string(path) {
|
||||
assert!(
|
||||
!source.contains(forbidden),
|
||||
"{} references a sibling DS4 checkout",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let forbidden = format!("{}/", ["..", "ds4"].join("/"));
|
||||
for path in ["src", "native", "build.rs", "Cargo.toml", "Makefile"] {
|
||||
scan(&root.join(path), &forbidden);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user