Skip to content

feat: 将 command.rs 中的 ffmpeg 相关代码抽离到 helper/ffmp.rs 中, 同时将转发的Commad 改为异步#54

Merged
GuoJikun merged 5 commits into
mainfrom
copilot/move-ffmpeg-code-to-helper
May 9, 2026
Merged

feat: 将 command.rs 中的 ffmpeg 相关代码抽离到 helper/ffmp.rs 中, 同时将转发的Commad 改为异步#54
GuoJikun merged 5 commits into
mainfrom
copilot/move-ffmpeg-code-to-helper

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 9, 2026

The previous refactor moved ffmpeg logic into helper/ffmp.rs but left #[command] attributes there too, mixing Tauri command layer concerns with implementation logic.

Changes

  • helper/ffmp.rs — Removed use tauri::command and all #[command] attributes; functions are now plain pub fn implementations
  • command.rs — Replaced pub use ffmp::{...} re-exports with explicit #[command] wrappers that delegate to ffmp:::
#[command]
pub fn check_ffmpeg() -> bool { ffmp::check_ffmpeg() }

#[command]
pub fn convert_video_to_hls(path: &str) -> Result<String, String> { ffmp::convert_video_to_hls(path) }

#[command]
pub fn cancel_video_conversion() { ffmp::cancel_video_conversion() }

lib.rs and the invoke_handler registration are unchanged.

@GuoJikun GuoJikun marked this pull request as ready for review May 9, 2026 03:41
Copilot AI review requested due to automatic review settings May 9, 2026 03:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR separates Tauri command-layer concerns from the ffmpeg implementation by moving #[command]-annotated entrypoints back into command.rs, while keeping helper/ffmp.rs as a plain Rust implementation module.

Changes:

  • Exposed helper::ffmp from helper/mod.rs.
  • Refactored helper/ffmp.rs to contain only pure pub fn implementations (no tauri::command usage).
  • Added #[command] wrappers in command.rs that delegate to helper::ffmp, and updated clear_cache to call ffmp::clear_ffmpeg_cache().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src-tauri/src/helper/mod.rs Exposes the new ffmp helper module.
src-tauri/src/helper/ffmp.rs Holds ffmpeg/HLS implementation logic without Tauri command attributes.
src-tauri/src/command.rs Adds Tauri #[command] wrappers delegating to helper::ffmp and updates cache clearing call site.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src-tauri/src/helper/ffmp.rs Outdated

// 同一文件若已在转换中,直接等待播放列表就绪并返回,避免重复启动 ffmpeg。
{
let guard = FFMPEG_PROCESS.lock().unwrap();
@GuoJikun GuoJikun merged commit 30dd3ef into main May 9, 2026
2 checks passed
@GuoJikun GuoJikun deleted the copilot/move-ffmpeg-code-to-helper branch May 9, 2026 07:01
@GuoJikun GuoJikun changed the title refactor: keep #[command] in command.rs, pure impl in helper/ffmp.rs feat: 将 command.rs 中的 ffmpeg 相关代码抽离到 helper/ffmp.rs 中, 同时将转发的Commad 改为异步 May 9, 2026
@GuoJikun GuoJikun mentioned this pull request May 9, 2026
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants