Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

fix: Cross-platform OS hardening, data durability, and UI hit-testing fixes

Samir Hossains67484c9fa356
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c50cbcc..4ebe869 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,20 @@
## [Unreleased]
+### Fixed
+- **Season Download Stream Error Recovery**: Prevented download queue stalls when resolving individual episode stream URLs fails; failed streams report diagnostics and allow the remaining queue to continue.
+- **Favorites & Watch History Corruption Recovery**: Corrupted JSON configuration and history state files now rotate to `.corrupt` backups instead of hard deletion, preserving recoverable user data.
+- **Details Screen Hit-Testing & Selector Alignment**: Aligned mouse hit-testing regions and season/episode selector column geometry across all compact, medium, and wide terminal tiers.
+- **Unicode Display Width in Input Widgets**: Single-line text input fields now compute column offsets using visual Unicode width instead of raw character counts, preventing CJK and multi-byte character overflow from wrapping box borders.
+- **M3U Playlist Channel Title Parsing**: Channel titles containing commas in `#EXTINF` metadata are now parsed without truncation, preserving complete channel display names.
+- **Subtitle Cache Purge Path Alignment**: Aligned `purge_stale_subtitles` with `resolve_subtitle_dir()` to ensure downloaded subtitle sidecars are cleaned automatically on startup.
+- **Android Termux Directory Resolution**: Added comprehensive fallback resolution for config, cache, and data directories when `dirs::*` returns `None` on Android Termux.
+- **Android Termux Self-Update Protection**: Added architecture guard preventing Termux from downloading incompatible glibc Linux ARM64 binaries that overwrite working Bionic installations.
+- **Windows UNC & Extended Path Escaping**: Preserved leading backslashes on Windows UNC (`\\server\share`) and extended-length (`\\?\`) paths when formatting player arguments.
+- **Windows Update Helper `find.exe` Qualification**: Explicitly qualified `%SystemRoot%\System32\find.exe` in the update helper `.bat` script to prevent shadowing by Git for Windows' `find.exe`.
+- **Windows NTFS Forbidden Character Sanitization**: Hardened tracker state file generation by stripping control characters and NTFS forbidden characters (`*`, `?`, `"`, `<`, `>`, `|`, `:`).
+- **Update Modal Keystroke Fallthrough**: Allowed non-modal navigation keystrokes to fall through to the active screen while the update banner is displayed.
+
### Changed
- **Responsive Mode Tabs**: Mode tabs on compact viewports dynamically abbreviate to `<76` (`[Ctrl+S] Stream`) and ultra-compact `<58` (`[S] Stream`), protecting them against collisions with the right-aligned utility bar.
- **TV Mode Logo Responsiveness**: Terminal width `<80` triggers the narrower 33-column compact logo to render in TV mode, establishing clean margins on medium setups.
diff --git a/src/config.rs b/src/config.rs
index 199d628..b5d93e9 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -43,22 +43,70 @@ pub fn config_dir() -> Option<PathBuf> {
if let Ok(dir) = std::env::var("MOVIEBOX_CONFIG_DIR") {
return Some(PathBuf::from(dir));
}
- dirs::config_dir().map(|dir| dir.join(APP_NAME))
+ if let Some(dir) = dirs::config_dir() {
+ return Some(dir.join(APP_NAME));
+ }
+ if let Ok(xdg) = std::env::var("XDG_CONFIG_HOME") {
+ let p = PathBuf::from(xdg);
+ if !p.as_os_str().is_empty() {
+ return Some(p.join(APP_NAME));
+ }
+ }
+ if let Ok(prefix) = std::env::var("PREFIX") {
+ let p = PathBuf::from(prefix).join("etc").join(APP_NAME);
+ if p.exists() {
+ return Some(p);
+ }
+ }
+ dirs::home_dir().map(|h| h.join(".config").join(APP_NAME))
}
pub fn data_dir() -> Option<PathBuf> {
if let Ok(dir) = std::env::var("MOVIEBOX_DATA_DIR") {
return Some(PathBuf::from(dir));
}
- dirs::data_dir().map(|dir| dir.join(APP_NAME))
+ if let Some(dir) = dirs::data_dir() {
+ return Some(dir.join(APP_NAME));
+ }
+ if let Ok(xdg) = std::env::var("XDG_DATA_HOME") {
+ let p = PathBuf::from(xdg);
+ if !p.as_os_str().is_empty() {
+ return Some(p.join(APP_NAME));
+ }
+ }
+ if let Ok(prefix) = std::env::var("PREFIX") {
+ let p = PathBuf::from(prefix).join("var").join("lib").join(APP_NAME);
+ if p.exists() {
+ return Some(p);
+ }
+ }
+ dirs::home_dir().map(|h| h.join(".local").join("share").join(APP_NAME))
}
pub fn cache_dir() -> PathBuf {
if let Ok(dir) = std::env::var("MOVIEBOX_CACHE_DIR") {
return PathBuf::from(dir);
}
- dirs::cache_dir()
- .map(|dir| dir.join(APP_NAME))
+ if let Some(dir) = dirs::cache_dir() {
+ return dir.join(APP_NAME);
+ }
+ if let Ok(xdg) = std::env::var("XDG_CACHE_HOME") {
+ let p = PathBuf::from(xdg);
+ if !p.as_os_str().is_empty() {
+ return p.join(APP_NAME);
+ }
+ }
+ if let Ok(prefix) = std::env::var("PREFIX") {
+ let p = PathBuf::from(prefix)
+ .join("var")
+ .join("cache")
+ .join(APP_NAME);
+ if p.exists() {
+ return p;
+ }
+ }
+ dirs::home_dir()
+ .map(|h| h.join(".cache").join(APP_NAME))
.unwrap_or_else(|| std::env::temp_dir().join(APP_NAME))
}
diff --git a/src/favorites.rs b/src/favorites.rs
index 6277f89..7b0c268 100644
--- a/src/favorites.rs
+++ b/src/favorites.rs
@@ -50,7 +50,17 @@ impl FavoritesManager {
return manager;
}
}
- let _ = fs::remove_file(path);
+ let stamp = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs();
+ let corrupt_path = path.with_extension(format!("corrupt.{stamp}"));
+ log::error!(
+ "failed to parse favorites from {}, rotating to {}",
+ crate::logging::sanitize_path(path),
+ crate::logging::sanitize_path(&corrupt_path)
+ );
+ let _ = fs::rename(path, corrupt_path);
}
Self::default()
}
@@ -298,6 +308,11 @@ mod tests {
let loaded = FavoritesManager::load_from_path(&path);
assert!(loaded.items.is_empty());
assert!(!path.exists());
+ let corrupt_exists = std::fs::read_dir(&temp_dir)
+ .unwrap()
+ .flatten()
+ .any(|e| e.file_name().to_string_lossy().contains("corrupt"));
+ assert!(corrupt_exists, "expected .corrupt backup file");
let _ = std::fs::remove_dir_all(&temp_dir);
}
diff --git a/src/history.rs b/src/history.rs
index 7d001f1..6996801 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -155,7 +155,17 @@ impl HistoryManager {
hist.hydrate_watched_index();
hist
} else {
- let _ = fs::remove_file(&path);
+ let stamp = std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs();
+ let corrupt_path = path.with_extension(format!("corrupt.{stamp}"));
+ log::error!(
+ "failed to parse watch history from {}, rotating to {}",
+ crate::logging::sanitize_path(&path),
+ crate::logging::sanitize_path(&corrupt_path)
+ );
+ let _ = fs::rename(&path, corrupt_path);
Self::default()
}
} else {
@@ -320,6 +330,7 @@ impl HistoryManager {
let excess = self.recent.len() - 100;
self.recent.drain(0..excess);
}
+ self.save();
}
pub fn update_progress(
diff --git a/src/main.rs b/src/main.rs
index 1e1998d..ac97047 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,7 +22,10 @@ fn restore_terminal() {
fn purge_stale_subtitles() {
tokio::task::spawn_blocking(|| {
let max_age = 24 * 60 * 60;
- let mut dirs = vec![std::env::temp_dir().join("moviebox-tui/subs")];
+ let mut dirs = vec![
+ moviebox_tui::service::resolve_subtitle_dir(),
+ std::env::temp_dir().join("moviebox-tui/subs"),
+ ];
if let Some(home) = dirs::home_dir() {
let android_storage = home.join("storage/downloads/moviebox_subs");
if home.join("storage/downloads").exists() {
diff --git a/src/player.rs b/src/player.rs
index 4bb2ccf..be54b14 100644
--- a/src/player.rs
+++ b/src/player.rs
@@ -294,7 +294,7 @@ fn mpv_command(
if let Some((provider, subject_id, season, episode)) = tracker {
if let Some(script_path) = tracker::ensure_tracker_script() {
- let script_str = script_path.to_string_lossy().replace('\\', "/");
+ let script_str = normalize_player_path(&script_path.to_string_lossy());
command.arg(format!("{prefix}script={script_str}"));
if let Some(state_file) =
tracker::state_file_path(provider, subject_id, season, episode)
@@ -320,7 +320,7 @@ fn mpv_command(
} else {
"--sub-file"
};
- let sub_path = subtitle.replace('\\', "/");
+ let sub_path = normalize_player_path(subtitle);
command.arg(format!("{opt}={sub_path}"));
}
@@ -433,7 +433,7 @@ fn vlc_command(
}
}
if let Some(subtitle) = subtitle {
- let sub_path = subtitle.replace('\\', "/");
+ let sub_path = normalize_player_path(subtitle);
command.arg(format!("--sub-file={sub_path}"));
}
@@ -744,6 +744,14 @@ fn executable_on_path(name: &str) -> bool {
find_in_path(name).is_some()
}
+fn normalize_player_path(path: &str) -> String {
+ if path.starts_with(r"\\") || path.starts_with("//") {
+ path.to_string()
+ } else {
+ path.replace('\\', "/")
+ }
+}
+
pub fn format_mpv_script_opts(
provider: &str,
subject_id: &str,
@@ -751,7 +759,7 @@ pub fn format_mpv_script_opts(
episode: usize,
state_file: &Path,
) -> String {
- let state_file_str = state_file.to_string_lossy().replace('\\', "/");
+ let state_file_str = normalize_player_path(&state_file.to_string_lossy());
format!(
"moviebox-provider={provider},moviebox-subject_id={subject_id},moviebox-season={season},moviebox-episode={episode},moviebox-state_file={state_file_str}"
)
@@ -831,6 +839,21 @@ mod tests {
)
);
}
+ #[test]
+ fn vlc_command_preserves_unc_subtitle_paths() {
+ let command = vlc_command(
+ "https://example.test/video.mp4",
+ Some(r"\\server\share\subs\sub.srt"),
+ &[],
+ None,
+ None,
+ );
+ let args = command
+ .get_args()
+ .map(|arg| arg.to_string_lossy().into_owned())
+ .collect::<Vec<_>>();
+ assert!(args.contains(&r"--sub-file=\\server\share\subs\sub.srt".into()));
+ }
#[test]
fn header_support_rejects_android_and_unsupported_vlc_headers() {
diff --git a/src/player/tracker.rs b/src/player/tracker.rs
index df9399a..3fe59b7 100644
--- a/src/player/tracker.rs
+++ b/src/player/tracker.rs
@@ -101,7 +101,28 @@ pub fn state_file_path(
}
fn sanitize_component(value: &str) -> String {
- value.replace(['/', '\\', ':', ' '], "_")
+ let sanitized = value
+ .chars()
+ .take(120)
+ .map(|character| {
+ if character.is_control()
+ || matches!(
+ character,
+ '/' | '\\' | ':' | '*' | '?' | '"' | '<' | '>' | '|' | ' '
+ )
+ {
+ '_'
+ } else {
+ character
+ }
+ })
+ .collect::<String>();
+ let trimmed = sanitized.trim_matches(['.', ' ', '_']);
+ if trimmed.is_empty() {
+ "unknown".to_string()
+ } else {
+ trimmed.to_string()
+ }
}
#[cfg(test)]
@@ -118,5 +139,9 @@ mod tests {
sanitize_component("subject:with space"),
"subject_with_space"
);
+ assert_eq!(
+ sanitize_component("subject*with?forbidden<chars>|quote\""),
+ "subject_with_forbidden_chars__quote"
+ );
}
}
diff --git a/src/providers/tv/parser.rs b/src/providers/tv/parser.rs
index eaadbc4..0b7ec29 100644
--- a/src/providers/tv/parser.rs
+++ b/src/providers/tv/parser.rs
@@ -135,7 +135,7 @@ impl M3UParser {
current_channel.logo = extract_attr(line, "tvg-logo");
current_channel.group = extract_attr(line, "group-title");
- if let Some(idx) = line.rfind(',') {
+ if let Some(idx) = find_extinf_title_comma(line) {
current_channel.name = line[idx + 1..].trim().to_string();
}
} else if !line.starts_with('#') {
@@ -159,6 +159,19 @@ impl M3UParser {
}
}
+fn find_extinf_title_comma(line: &str) -> Option<usize> {
+ let mut in_quote: Option<char> = None;
+ for (idx, ch) in line.char_indices() {
+ match in_quote {
+ Some(quote) if ch == quote => in_quote = None,
+ None if ch == '"' || ch == '\'' => in_quote = Some(ch),
+ None if ch == ',' => return Some(idx),
+ _ => {}
+ }
+ }
+ line.find(',')
+}
+
fn cache_filename(raw: &str) -> String {
format!("{}.m3u", crate::cache::md5_hex(raw))
}
@@ -198,4 +211,20 @@ http://example.com/discovery.m3u8
assert_eq!(channels[2].group, "");
assert_eq!(channels[2].stream_url, "http://example.com/discovery.m3u8");
}
+
+ #[test]
+ fn test_parse_m3u_title_with_commas_and_quoted_attributes() {
+ let parser = M3UParser::new();
+ let content = r#"#EXTM3U
+#EXTINF:-1 tvg-id="cnn.us" group-title="News, International",CNN, The Worldwide News Leader
+http://example.com/cnn.m3u8
+#EXTINF:0,Movie Channel, HD (US), 24/7
+http://example.com/movie.m3u8
+"#;
+ let channels = parser.parse_m3u(content);
+ assert_eq!(channels.len(), 2);
+ assert_eq!(channels[0].name, "CNN, The Worldwide News Leader");
+ assert_eq!(channels[0].group, "News, International");
+ assert_eq!(channels[1].name, "Movie Channel, HD (US), 24/7");
+ }
}
diff --git a/src/tui/app/keyboard.rs b/src/tui/app/keyboard.rs
index 7640e6b..723fb07 100644
--- a/src/tui/app/keyboard.rs
+++ b/src/tui/app/keyboard.rs
@@ -119,6 +119,7 @@ impl App {
match key.code {
KeyCode::Char('u') | KeyCode::Char('U') => {
self.action_sender.send(Action::StartSelfUpdate).ok();
+ return None;
}
KeyCode::Char('o') | KeyCode::Char('O') => {
let url = format!(
@@ -127,13 +128,14 @@ impl App {
);
let _ = open::that(&url);
self.state.update_available = None;
+ return None;
}
KeyCode::Esc => {
self.state.update_available = None;
+ return None;
}
_ => {}
}
- return None;
}
if self.state.show_browse_popup {
@@ -1298,10 +1300,49 @@ mod tests {
app.handle_key(KeyEvent::new(KeyCode::Char('G'), KeyModifiers::SHIFT))
.await;
assert_eq!(app.state.search_list_state.selected(), Some(2));
-
// Jump to Home with g
app.handle_key(KeyEvent::new(KeyCode::Char('g'), KeyModifiers::empty()))
.await;
assert_eq!(app.state.search_list_state.selected(), Some(0));
}
+
+ #[tokio::test]
+ async fn test_update_modal_keystroke_fallthrough() {
+ let mut app = App::new();
+ app.state.active_screen = crate::tui::state::Screen::Home;
+ app.state.input_mode = InputMode::Normal;
+ app.state.update_available = Some(("2.0.0".to_string(), "Notes".to_string()));
+ app.state.search_results = vec![
+ crate::models::SearchResult {
+ id: "1".to_string(),
+ title: "Movie 1".to_string(),
+ stype: 1,
+ release_year: "2020".to_string(),
+ provider: crate::models::ProviderKind::MovieBox,
+ cover_url: None,
+ season: 0,
+ episode: 0,
+ },
+ crate::models::SearchResult {
+ id: "2".to_string(),
+ title: "Movie 2".to_string(),
+ stype: 1,
+ release_year: "2021".to_string(),
+ provider: crate::models::ProviderKind::MovieBox,
+ cover_url: None,
+ season: 0,
+ episode: 0,
+ },
+ ];
+ app.state.search_list_state.select(Some(0));
+
+ // End key should fall through and jump to end of search list
+ app.handle_key(KeyEvent::new(KeyCode::End, KeyModifiers::empty()))
+ .await;
+ assert_eq!(app.state.search_list_state.selected(), Some(1));
+ // Esc should dismiss the update modal
+ app.handle_key(KeyEvent::new(KeyCode::Esc, KeyModifiers::empty()))
+ .await;
+ assert!(app.state.update_available.is_none());
+ }
}
diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rs
index adf57d9..b18605b 100644
--- a/src/tui/app/mouse.rs
+++ b/src/tui/app/mouse.rs
@@ -703,19 +703,16 @@ impl App {
return None;
}
- let visible_selector_panes = if matches!(
- tier,
- crate::tui::screens::details::DetailsLayoutTier::Narrow
- | crate::tui::screens::details::DetailsLayoutTier::Tiny
- ) {
- available_panes
- .iter()
- .copied()
- .filter(|pane| *pane == self.state.details_pane)
- .collect::<Vec<_>>()
- } else {
- available_panes
- };
+ let visible_selector_panes =
+ if matches!(tier, crate::tui::screens::details::DetailsLayoutTier::Tiny) {
+ available_panes
+ .iter()
+ .copied()
+ .filter(|pane| *pane == self.state.details_pane)
+ .collect::<Vec<_>>()
+ } else {
+ available_panes
+ };
let selector_height = if visible_selector_panes.is_empty() {
0
@@ -732,7 +729,7 @@ impl App {
language_count
.max(self.state.available_seasons.len())
.max(episode_count)
- .min(4) as u16
+ .min((bottom_area.height / 3).clamp(4, 10) as usize) as u16
+ 2
};
diff --git a/src/tui/app/requests.rs b/src/tui/app/requests.rs
index e5c2246..3e6a60e 100644
--- a/src/tui/app/requests.rs
+++ b/src/tui/app/requests.rs
@@ -2057,6 +2057,15 @@ impl App {
);
self.state.stream_error = Some(err.clone());
self.state.set_status_default(format!("Error: {}", err));
+ if self.state.is_waiting_for_download_stream {
+ self.state.is_waiting_for_download_stream = false;
+ self.action_sender
+ .send(Action::DownloadFailed(format!(
+ "Failed to resolve streams for S{:02}E{:02}: {}",
+ target_se, target_ep, err
+ )))
+ .ok();
+ }
}
_ => return None,
}
diff --git a/src/tui/widgets/input.rs b/src/tui/widgets/input.rs
index 233b910..1ec1a22 100644
--- a/src/tui/widgets/input.rs
+++ b/src/tui/widgets/input.rs
@@ -18,38 +18,67 @@ pub fn render_single_line_input(
) {
let segments = buffer.graphemes();
let cursor = buffer.cursor();
- let max_width = (area.width as usize).saturating_sub(6);
+ let prompt_symbol = if basic_terminal { " > " } else { " ❯ " };
+ let prompt_width = crate::tui::text::width(prompt_symbol);
+ let available_width = (area.width as usize)
+ .saturating_sub(prompt_width + 1)
+ .max(1);
+
+ let cursor_grapheme = if cursor < segments.len() {
+ segments[cursor]
+ } else {
+ " "
+ };
+ let cursor_w = crate::tui::text::width(cursor_grapheme).max(1);
- let mut start = 0;
- if cursor >= max_width {
- start = cursor - max_width + 1;
+ let max_before_w = available_width.saturating_sub(cursor_w);
+ let mut start = cursor;
+ let mut current_before_w = 0;
+ while start > 0 {
+ let prev_gw = crate::tui::text::width(segments[start - 1]);
+ if current_before_w + prev_gw > max_before_w {
+ break;
+ }
+ current_before_w += prev_gw;
+ start -= 1;
}
let mut before_cursor: String = segments[start..cursor].concat();
- if start > 0 && before_cursor.chars().count() > 3 {
- before_cursor = format!("...{}", before_cursor.chars().skip(3).collect::<String>());
+ if start > 0 {
+ let before_w = crate::tui::text::width(&before_cursor);
+ if before_w > 3 {
+ before_cursor = format!(
+ "...{}",
+ crate::tui::text::truncate_width(&before_cursor, before_w.saturating_sub(3))
+ );
+ }
}
- let cursor_char = if cursor < segments.len() {
- segments[cursor].to_string()
- } else {
- " ".to_string()
- };
+ let cursor_char = cursor_grapheme.to_string();
+
+ let remaining_after_w = available_width.saturating_sub(current_before_w + cursor_w);
+ let mut end = cursor.saturating_add(1).min(segments.len());
+ let mut current_after_w = 0;
+ while end < segments.len() {
+ let next_gw = crate::tui::text::width(segments[end]);
+ if current_after_w + next_gw > remaining_after_w {
+ break;
+ }
+ current_after_w += next_gw;
+ end += 1;
+ }
- let end = (start + max_width).min(segments.len());
let after_slice = &segments[cursor.saturating_add(1).min(segments.len())..end];
let mut after_cursor: String = after_slice.concat();
if end < segments.len() {
- let len = after_cursor.chars().count();
- if len > 3 {
- let keep: String = after_cursor.chars().take(len - 3).collect();
+ let after_w = crate::tui::text::width(&after_cursor);
+ if after_w > 3 {
+ let keep = crate::tui::text::truncate_width(&after_cursor, after_w.saturating_sub(3));
after_cursor = format!("{keep}...");
} else if !after_cursor.is_empty() {
after_cursor = "...".to_string();
}
}
-
- let prompt_symbol = if basic_terminal { " > " } else { " ❯ " };
let lines = vec![
Line::from(vec![Span::raw(" "), Span::styled(label, theme.sapphire)]),
Line::from(vec![
@@ -110,4 +139,24 @@ mod tests {
})
.unwrap();
}
+ #[test]
+ fn test_render_single_line_input_cjk_no_wrap() {
+ let backend = TestBackend::new(30, 5);
+ let mut terminal = Terminal::new(backend).unwrap();
+ let buffer = TextInputBuffer::from_str("https://example.com/电影/电视/动漫/超高清.m3u8");
+ let theme = Theme::default();
+
+ terminal
+ .draw(|f| {
+ render_single_line_input(
+ f,
+ Rect::new(0, 0, 30, 3),
+ "Enter URL:",
+ &buffer,
+ &theme,
+ false,
+ );
+ })
+ .unwrap();
+ }
}
diff --git a/src/updater/apply.rs b/src/updater/apply.rs
index 7c8a1a4..967b491 100644
--- a/src/updater/apply.rs
+++ b/src/updater/apply.rs
@@ -176,7 +176,9 @@ fn render_helper_script(staged_path: &Path, current_exe: &Path, pid: u32) -> Str
[
"@echo off".to_string(),
":wait_loop".to_string(),
- format!("tasklist /FI \"PID eq {pid}\" 2>NUL | find \"{pid}\" >NUL"),
+ format!(
+ "tasklist /FI \"PID eq {pid}\" 2>NUL | %SystemRoot%\\System32\\find.exe \"{pid}\" >NUL"
+ ),
"if %ERRORLEVEL% == 0 (".to_string(),
" timeout /t 1 /nobreak >NUL".to_string(),
" goto wait_loop".to_string(),
@@ -268,7 +270,9 @@ mod tests {
);
let lines: Vec<&str> = script.split("\r\n").collect();
assert_eq!(lines[0], "@echo off");
- assert!(script.contains("tasklist /FI \"PID eq 4242\""));
+ assert!(script.contains(
+ "tasklist /FI \"PID eq 4242\" 2>NUL | %SystemRoot%\\System32\\find.exe \"4242\" >NUL"
+ ));
assert!(script.contains(
"move /y \"C:\\App\\update dir\\.moviebox_update_staged.exe\" \"C:\\App\\moviebox-tui.exe\""
));
diff --git a/src/updater/artifact.rs b/src/updater/artifact.rs
index 8c3759c..776b86f 100644
--- a/src/updater/artifact.rs
+++ b/src/updater/artifact.rs
@@ -32,12 +32,8 @@ impl TargetPlatform {
}
pub fn detect(os: &str, arch: &str, is_termux: bool) -> Option<Self> {
- if is_termux {
- if arch == "aarch64" || arch == "arm64" {
- return Some(Self::LinuxArm64);
- } else {
- return None;
- }
+ if is_termux || os == "android" {
+ return None;
}
match os {
@@ -75,7 +71,10 @@ impl TargetPlatform {
}
pub fn is_termux_environment() -> bool {
- std::env::var("PREFIX").is_ok_and(|p| p.contains("com.termux"))
+ cfg!(target_os = "android")
+ || std::env::var("TERMUX_VERSION").is_ok()
+ || std::env::var("PREFIX").is_ok_and(|p| p.contains("com.termux"))
+ || std::path::Path::new("/data/data/com.termux/files/usr").exists()
}
impl Release {
diff --git a/src/updater/mod.rs b/src/updater/mod.rs
index ccc448c..66ec87d 100644
--- a/src/updater/mod.rs
+++ b/src/updater/mod.rs
@@ -258,15 +258,10 @@ mod tests {
}
#[test]
- fn test_update_asset_termux_arm64_selection() {
- let release = sample_release_with_all_assets();
- let termux_arm64 = TargetPlatform::detect("linux", "aarch64", true).unwrap();
- assert_eq!(termux_arm64, TargetPlatform::LinuxArm64);
-
- let asset = release.find_compatible_asset(termux_arm64).unwrap();
- assert_eq!(asset.name, "MovieBox_Linux_arm64.tar.gz");
-
+ fn test_update_asset_termux_is_protected_from_glibc_binary() {
+ assert!(TargetPlatform::detect("linux", "aarch64", true).is_none());
assert!(TargetPlatform::detect("linux", "x86_64", true).is_none());
+ assert!(TargetPlatform::detect("android", "aarch64", false).is_none());
}
#[test]