Refactor settings import to use legacy/Heimgeist settings instead of Electron settings
This commit is contained in:
@@ -264,7 +264,7 @@ fn push_unique_candidate(candidates: &mut Vec<PathBuf>, candidate: PathBuf, taur
|
|||||||
candidates.push(candidate);
|
candidates.push(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn electron_settings_candidates(app: &AppHandle, tauri_path: &Path) -> Vec<PathBuf> {
|
fn legacy_settings_candidates(app: &AppHandle, tauri_path: &Path) -> Vec<PathBuf> {
|
||||||
let mut candidates = Vec::new();
|
let mut candidates = Vec::new();
|
||||||
|
|
||||||
if let Ok(config_dir) = app.path().config_dir() {
|
if let Ok(config_dir) = app.path().config_dir() {
|
||||||
@@ -282,15 +282,12 @@ fn electron_settings_candidates(app: &AppHandle, tauri_path: &Path) -> Vec<PathB
|
|||||||
candidates
|
candidates
|
||||||
}
|
}
|
||||||
|
|
||||||
fn import_electron_settings_if_available(
|
fn import_legacy_settings_if_available(app: &AppHandle, tauri_path: &Path) -> Option<SettingsMap> {
|
||||||
app: &AppHandle,
|
for candidate in legacy_settings_candidates(app, tauri_path) {
|
||||||
tauri_path: &Path,
|
|
||||||
) -> Option<SettingsMap> {
|
|
||||||
for candidate in electron_settings_candidates(app, tauri_path) {
|
|
||||||
match read_settings_file(&candidate) {
|
match read_settings_file(&candidate) {
|
||||||
Ok(Some(settings)) => {
|
Ok(Some(settings)) => {
|
||||||
println!(
|
println!(
|
||||||
"Imported Electron settings for first Tauri run from {}",
|
"Imported legacy Heimgeist settings for first Tauri run from {}",
|
||||||
candidate.display()
|
candidate.display()
|
||||||
);
|
);
|
||||||
return Some(settings);
|
return Some(settings);
|
||||||
@@ -298,7 +295,7 @@ fn import_electron_settings_if_available(
|
|||||||
Ok(None) => {}
|
Ok(None) => {}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Skipping Electron settings import from {}: {error}",
|
"Skipping legacy settings import from {}: {error}",
|
||||||
candidate.display()
|
candidate.display()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -350,7 +347,7 @@ fn load_settings_store(app: &AppHandle) -> Result<SettingsStore, String> {
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let imported_settings = if explicit_settings_file_path().is_none() {
|
let imported_settings = if explicit_settings_file_path().is_none() {
|
||||||
import_electron_settings_if_available(app, &path)
|
import_legacy_settings_if_available(app, &path)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user