Implement Upload Hook for momentry integration (Phase 1)
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

- Add upload_hook.rs module: trigger video_probe + video_register on upload
- Add UploadHookSection to config: video extensions, binary paths
- Integrate with SFTP: handle_close triggers hook on write files
- Integrate with SCP/rsync: child process exit triggers hook
- All 155 tests pass
This commit is contained in:
Warren
2026-06-19 06:26:20 +08:00
parent c71811090b
commit e2d58538f9
7 changed files with 336 additions and 42 deletions

View File

@@ -18,6 +18,8 @@ pub struct AppConfig {
pub sftp: SftpSection,
#[serde(default)]
pub ssh: SshSection,
#[serde(default)]
pub upload_hook: UploadHookSection,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -116,6 +118,36 @@ impl Default for SshSection {
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UploadHookSection {
pub enabled: bool,
pub video_probe_path: String,
pub video_register_cli: String,
pub video_register_dir: String,
pub video_extensions: Vec<String>,
}
impl Default for UploadHookSection {
fn default() -> Self {
Self {
enabled: false,
video_probe_path: "/Users/accusys/momentry_core_project/video_probe/target/release/video_probe".to_string(),
video_register_cli: "cli.py".to_string(),
video_register_dir: "/Users/accusys/momentry_core_project/video_register".to_string(),
video_extensions: vec![
"mp4".to_string(),
"mov".to_string(),
"avi".to_string(),
"mkv".to_string(),
"webm".to_string(),
"flv".to_string(),
"wmv".to_string(),
"m4v".to_string(),
],
}
}
}
impl AppConfig {
pub fn load(path: &str) -> Result<Self> {
let config_path = std::path::PathBuf::from(path);
@@ -176,6 +208,9 @@ impl AppConfig {
self.web.auth_db_path = v.clone();
self.sftp.auth_db_path = v;
}
if let Ok(v) = std::env::var("MB_UPLOAD_HOOK_ENABLED") {
self.upload_hook.enabled = v == "true" || v == "1";
}
}
}
@@ -192,6 +227,8 @@ mod tests {
assert_eq!(config.ssh.port, 2024);
assert_eq!(config.sftp.port, 2023);
assert_eq!(config.s3.region, "us-east-1");
assert!(!config.upload_hook.enabled);
assert!(config.upload_hook.video_extensions.contains(&"mp4".to_string()));
}
#[test]