diff --git a/src-tauri/src/commands/app_lifecycle.rs b/src-tauri/src/commands/app_lifecycle.rs index 6b721b87..129a741a 100644 --- a/src-tauri/src/commands/app_lifecycle.rs +++ b/src-tauri/src/commands/app_lifecycle.rs @@ -24,3 +24,31 @@ pub fn get_debug_info(app: AppHandle) -> DebugInfo { proxy_enabled: settings.proxy.enabled, } } + +#[derive(Debug, Serialize)] +pub struct PortableInfo { + pub is_portable: bool, + pub data_dir: Option, + /// Whether the UI should warn that the WebView is not portable here. + /// + /// Only macOS: wry does not read `data_directory` on WKWebView, so the + /// session data stays under `~/Library` no matter where the app runs from. + /// Windows and Linux redirect it in `lib.rs`, so there is nothing to warn + /// about there. See issue #227. + pub macos_webview_notice: bool, +} + +/// Reports what portable mode actually covers on this platform. +/// +/// Reads the same environment `main.rs` publishes rather than re-detecting +/// `portable.txt`, so there is a single source of truth for the mode. +#[tauri::command] +pub fn get_portable_info() -> PortableInfo { + let is_portable = std::env::var("OMNIGET_PORTABLE").ok().as_deref() == Some("1"); + + PortableInfo { + is_portable, + data_dir: std::env::var("OMNIGET_DATA_DIR").ok(), + macos_webview_notice: cfg!(target_os = "macos") && is_portable, + } +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 5afb5fac..e4fd8143 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1007,6 +1007,7 @@ pub fn run() { commands::p2p::p2p_resume_send, commands::app_lifecycle::force_exit_app, commands::app_lifecycle::get_debug_info, + commands::app_lifecycle::get_portable_info, ]) .build(tauri::generate_context!()) .expect("error while building tauri application") diff --git a/src/components/settings/SettingsStorage.svelte b/src/components/settings/SettingsStorage.svelte index 90879ebf..9d1a34d8 100644 --- a/src/components/settings/SettingsStorage.svelte +++ b/src/components/settings/SettingsStorage.svelte @@ -25,7 +25,14 @@ map: { media_duration_secs: number; spans: unknown[] }; }; + type PortableInfo = { + is_portable: boolean; + data_dir: string | null; + macos_webview_notice: boolean; + }; + let stats = $state(null); + let portable = $state(null); let running = $state(false); let probing = $state(false); @@ -58,6 +65,14 @@ } } + async function loadPortable() { + try { + portable = await invoke("get_portable_info"); + } catch { + portable = null; + } + } + async function runDedupe() { const chosen = await open({ multiple: true, @@ -127,6 +142,7 @@ $effect(() => { void loadStats(); + void loadPortable(); }); @@ -134,6 +150,30 @@
{$t("settings.storage.title")}

{$t("settings.storage.description")}

+ {#if portable?.is_portable} +
+
+
+ {$t("settings.storage.portable_label")} + + {$t("settings.storage.portable_active", { dir: portable.data_dir ?? "/data" })} + +
+
+ + + {#if portable.macos_webview_notice} +
+
+
+ {$t("settings.storage.portable_macos_notice")} +
+
+ {/if} +
+ {/if} +
@@ -171,3 +211,17 @@
+ + diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json index 7913f5a3..95eb6af9 100644 --- a/src/lib/i18n/el.json +++ b/src/lib/i18n/el.json @@ -857,7 +857,10 @@ "silence_running": "Μέτρηση…", "pick_media": "Επιλέξτε αρχείο πολυμέσων", "silence_none": "Σχεδόν καθόλου σιωπή σε αυτό το αρχείο", - "silence_done": "Βρέθηκε σιωπή {{saved}} — ο player μπορεί να την προσπερνά" + "silence_done": "Βρέθηκε σιωπή {{saved}} — ο player μπορεί να την προσπερνά", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Εξαρτήσεις", diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 72880bd2..2a26699f 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -903,7 +903,10 @@ "silence_running": "Measuring…", "pick_media": "Pick a media file", "silence_none": "Almost no silence in this file", - "silence_done": "{{saved}} of silence found — playback can skip it" + "silence_done": "{{saved}} of silence found — playback can skip it", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Dependencies", diff --git a/src/lib/i18n/es.json b/src/lib/i18n/es.json index 0f725cf2..168fbd1a 100644 --- a/src/lib/i18n/es.json +++ b/src/lib/i18n/es.json @@ -857,7 +857,10 @@ "silence_running": "Midiendo…", "pick_media": "Elige un archivo multimedia", "silence_none": "Casi no hay silencio en este archivo", - "silence_done": "{{saved}} de silencio encontrado: el reproductor puede saltarlo" + "silence_done": "{{saved}} de silencio encontrado: el reproductor puede saltarlo", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Dependencias", diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json index 004340e3..f3546460 100644 --- a/src/lib/i18n/fr.json +++ b/src/lib/i18n/fr.json @@ -857,7 +857,10 @@ "silence_running": "Mesure en cours…", "pick_media": "Choisissez un fichier multimédia", "silence_none": "Presque aucun silence dans ce fichier", - "silence_done": "{{saved}} de silence trouvé — le lecteur peut le sauter" + "silence_done": "{{saved}} de silence trouvé — le lecteur peut le sauter", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Dépendances", diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json index 1bdd0602..e66b174c 100644 --- a/src/lib/i18n/it.json +++ b/src/lib/i18n/it.json @@ -857,7 +857,10 @@ "silence_running": "Misurazione…", "pick_media": "Scegli un file multimediale", "silence_none": "Quasi nessun silenzio in questo file", - "silence_done": "{{saved}} di silenzio trovato — il player può saltarlo" + "silence_done": "{{saved}} di silenzio trovato — il player può saltarlo", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Dipendenze", diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json index 803bdc63..f6e0704d 100644 --- a/src/lib/i18n/ja.json +++ b/src/lib/i18n/ja.json @@ -857,7 +857,10 @@ "silence_running": "測定中…", "pick_media": "メディアファイルを選択", "silence_none": "このファイルにはほとんど無音がありません", - "silence_done": "無音 {{saved}} 分を検出 — 再生時にスキップできます" + "silence_done": "無音 {{saved}} 分を検出 — 再生時にスキップできます", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "依存関係", diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.ts index 40f23dc5..3e286846 100644 --- a/src/lib/i18n/keys.ts +++ b/src/lib/i18n/keys.ts @@ -1555,6 +1555,9 @@ export type TranslationKeys = | 'settings.storage.description' | 'settings.storage.pick_files' | 'settings.storage.pick_media' + | 'settings.storage.portable_active' + | 'settings.storage.portable_label' + | 'settings.storage.portable_macos_notice' | 'settings.storage.silence_action' | 'settings.storage.silence_done' | 'settings.storage.silence_hint' diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json index a66bb712..4d6f3735 100644 --- a/src/lib/i18n/pt.json +++ b/src/lib/i18n/pt.json @@ -857,7 +857,10 @@ "silence_running": "Medindo…", "pick_media": "Escolha um arquivo de mídia", "silence_none": "Quase nenhum silêncio neste arquivo", - "silence_done": "{{saved}} de silêncio encontrado — o player pode pular" + "silence_done": "{{saved}} de silêncio encontrado — o player pode pular", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Dependências", diff --git a/src/lib/i18n/ru.json b/src/lib/i18n/ru.json index e037be71..00b89324 100644 --- a/src/lib/i18n/ru.json +++ b/src/lib/i18n/ru.json @@ -857,7 +857,10 @@ "silence_running": "Измерение…", "pick_media": "Выберите медиафайл", "silence_none": "В этом файле почти нет пауз", - "silence_done": "Найдено тишины: {{saved}} — плеер может её пропускать" + "silence_done": "Найдено тишины: {{saved}} — плеер может её пропускать", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "Зависимости", diff --git a/src/lib/i18n/zh-TW.json b/src/lib/i18n/zh-TW.json index 6f8b7604..84c5f3e6 100644 --- a/src/lib/i18n/zh-TW.json +++ b/src/lib/i18n/zh-TW.json @@ -857,7 +857,10 @@ "silence_running": "測量中…", "pick_media": "選擇一個媒體檔案", "silence_none": "這個檔案幾乎沒有靜音", - "silence_done": "發現 {{saved}} 的靜音 —— 播放時可以略過" + "silence_done": "發現 {{saved}} 的靜音 —— 播放時可以略過", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "相依元件", diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json index beafcf57..38d3552a 100644 --- a/src/lib/i18n/zh.json +++ b/src/lib/i18n/zh.json @@ -857,7 +857,10 @@ "silence_running": "测量中…", "pick_media": "选择一个媒体文件", "silence_none": "这个文件几乎没有静音", - "silence_done": "发现 {{saved}} 的静音 —— 播放时可以跳过" + "silence_done": "发现 {{saved}} 的静音 —— 播放时可以跳过", + "portable_label": "Portable Mode", + "portable_active": "Portable mode is active. OmniGet's data is stored in {{dir}}.", + "portable_macos_notice": "On macOS the WebView still stores its session data under ~/Library, and portable mode cannot redirect it. Only OmniGet's own data is portable here — see github.com/tonhowtf/omniget/issues/227." }, "dependencies": { "title": "依赖项",