Skip to content
Merged
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
28 changes: 28 additions & 0 deletions src-tauri/src/commands/app_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// 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,
}
}
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
54 changes: 54 additions & 0 deletions src/components/settings/SettingsStorage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<StoreStats | null>(null);
let portable = $state<PortableInfo | null>(null);
let running = $state(false);
let probing = $state(false);

Expand Down Expand Up @@ -58,6 +65,14 @@
}
}

async function loadPortable() {
try {
portable = await invoke<PortableInfo>("get_portable_info");
} catch {
portable = null;
}
}

async function runDedupe() {
const chosen = await open({
multiple: true,
Expand Down Expand Up @@ -127,13 +142,38 @@

$effect(() => {
void loadStats();
void loadPortable();
});
</script>

<section class="section">
<h5 class="section-title">{$t("settings.storage.title")}</h5>
<p class="muted">{$t("settings.storage.description")}</p>

{#if portable?.is_portable}
<div class="card portable-card">
<div class="setting-row">
<div class="setting-col">
<span class="setting-label">{$t("settings.storage.portable_label")}</span>
<span class="setting-path wrap">
{$t("settings.storage.portable_active", { dir: portable.data_dir ?? "<app>/data" })}
</span>
</div>
</div>

<!-- O modo portatil nao cobre o WebView no macOS, e o usuario que leva o
pendrive para outra maquina precisa saber disso antes, nao depois. -->
{#if portable.macos_webview_notice}
<div class="divider"></div>
<div class="setting-row">
<div class="setting-col">
<span class="setting-path wrap">{$t("settings.storage.portable_macos_notice")}</span>
</div>
</div>
{/if}
</div>
{/if}

<div class="card">
<div class="setting-row">
<div class="setting-col">
Expand Down Expand Up @@ -171,3 +211,17 @@
</div>
</div>
</section>

<style>
.portable-card {
margin-bottom: var(--padding);
}

/* O caminho de dados e o aviso do macOS sao frases inteiras, nao rotulos:
sem isto ficam numa linha so e sao cortados. */
.wrap {
white-space: normal;
word-break: break-word;
line-height: 1.5;
}
</style>
5 changes: 4 additions & 1 deletion src/lib/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Εξαρτήσεις",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "依存関係",
Expand Down
3 changes: 3 additions & 0 deletions src/lib/i18n/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Зависимости",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "相依元件",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "依赖项",
Expand Down
Loading