diff --git a/services/pddb/locales/i18n.json b/services/pddb/locales/i18n.json index ea1d44dea..c14513cdd 100644 --- a/services/pddb/locales/i18n.json +++ b/services/pddb/locales/i18n.json @@ -13,13 +13,6 @@ "ja": "パスワードを認証失敗でした。\n\nもう一度実行しください。", "zh": "密码错误。" }, - "pddb.waitmount": { - "en": "Mounting PDDB, please wait...", - "en-tts": "Mounting PDDB, please wait...", - "fr": "Montage de PDDB, veuillez patienter...*MT*", - "ja": "PDDB をマウントしています。お待ちください...", - "zh": "正在挂载 PDDB,请稍候..." - }, "pddb.basisname": { "en": "Basis Name:", "en-tts": "Enter name of Basis", @@ -300,6 +293,20 @@ "ja": "コミットルート\n(6/6)", "zh": "提交根(6/6)" }, + "pddb.unmount_previous": { + "en": "Warning: newly opened basis has the same name as a previously open basis. The previously opened basis has been closed.", + "en-tts": "Warning: newly opened basis has the same name as a previously open basis. The previously opened basis has been closed.", + "fr": "Attention : la base nouvellement ouverte porte le même nom qu'une base précédemment ouverte. La base précédemment ouverte a été fermée.*MT*", + "ja": "警告: 新しく開かれた基底は、以前に開いた基底と同じ名前です。 以前に開設されたベーシスは閉鎖されました。", + "zh": "警告:新打开的基础与以前打开的基础具有相同的名称。 之前打开的基础已经关闭。" + }, + "pddb.waitmount": { + "en": "Mounting PDDB, please wait...", + "en-tts": "Mounting PDDB, please wait...", + "fr": "Montage de PDDB, veuillez patienter...*MT*", + "ja": "PDDB をマウントしています。お待ちください...", + "zh": "正在挂载 PDDB,请稍候..." + }, "pddb.yes": { "en": "Yes", "en-tts": "Yes", diff --git a/services/pddb/src/backend/basis.rs b/services/pddb/src/backend/basis.rs index 782259a31..bc5377ad4 100644 --- a/services/pddb/src/backend/basis.rs +++ b/services/pddb/src/backend/basis.rs @@ -1001,6 +1001,15 @@ impl BasisCache { } } + pub(crate) fn basis_contains(&self, by_name: &str) -> bool { + for bcache in &self.cache { + if bcache.name == by_name { + return true + } + } + false + } + /// note: you can "delete" a basis simply by forgetting its password, but this is more thorough. /// there might also need to be a variant to make which is a "change my password" function, but that is actually /// surprisingly hard. diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index aaf630386..c0995b90f 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -876,6 +876,10 @@ fn wrapped_main() -> ! { &mut pddb_os, mgmt.name.as_str().expect("name is not valid utf-8"), pw.as_str().expect("password was not valid utf-8"), mgmt.policy.unwrap_or(BasisRetentionPolicy::Persist) ) { + if basis_cache.basis_contains(&basis.name) { + basis_cache.basis_unmount(&mut pddb_os, &basis.name).expect("couldn't unmount previously mounted basis of same name"); + modals.show_notification(t!("pddb.unmount_previous", xous::LANG), None).expect("notification failed"); + } basis_cache.basis_add(basis); finished = true; log::info!("{}PDDB.UNLOCKOK,{},{}", xous::BOOKEND_START, mgmt.name.as_str().unwrap(), xous::BOOKEND_END);