Fix ownership and borrowing issues in LivestreamArchiver

This commit is contained in:
RTSDA 2025-04-20 10:12:16 -04:00
parent cc7cf766cd
commit 5e3de7ec1c
2 changed files with 10 additions and 6 deletions

View file

@ -25,7 +25,7 @@ async fn main() -> Result<()> {
println!("Watching directory: {}", watch_path.display());
println!("Output directory: {}", output_path.display());
let archiver = LivestreamArchiver::new(&output_path.clone());
let archiver = LivestreamArchiver::new(output_path.clone());
let processed_files = Arc::new(Mutex::new(HashSet::new()));
// Process existing files first
@ -40,7 +40,7 @@ async fn main() -> Result<()> {
if let Some(filename) = path.file_name().and_then(|f| f.to_str()) {
if let Ok(date) = archiver.extract_date_from_filename(filename).await {
// Check if either Divine Worship or Afternoon Program exists for this date
let year_dir = archiver.output_path.join(date.format("%Y").to_string());
let year_dir = archiver.get_output_path().join(date.format("%Y").to_string());
let month_dir = year_dir.join(format!("{}-{}",
date.format("%m"),
date.format("%B")

View file

@ -4,16 +4,20 @@ use chrono::NaiveDateTime;
use tokio::process::Command;
use tokio::time::Duration;
pub struct LivestreamArchiver<'a> {
output_path: &'a PathBuf,
pub struct LivestreamArchiver {
output_path: PathBuf,
}
impl<'a> LivestreamArchiver<'a> {
pub fn new(output_path: &'a PathBuf) -> Self {
impl LivestreamArchiver {
pub fn new(output_path: PathBuf) -> Self {
LivestreamArchiver {
output_path,
}
}
pub fn get_output_path(&self) -> &PathBuf {
&self.output_path
}
async fn wait_for_file_ready(&self, path: &PathBuf) -> Result<()> {
println!("Waiting for file to be ready: {}", path.display());