Fix ownership and borrowing issues in LivestreamArchiver
This commit is contained in:
parent
cc7cf766cd
commit
5e3de7ec1c
|
@ -25,7 +25,7 @@ async fn main() -> Result<()> {
|
||||||
println!("Watching directory: {}", watch_path.display());
|
println!("Watching directory: {}", watch_path.display());
|
||||||
println!("Output directory: {}", output_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()));
|
let processed_files = Arc::new(Mutex::new(HashSet::new()));
|
||||||
|
|
||||||
// Process existing files first
|
// 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 Some(filename) = path.file_name().and_then(|f| f.to_str()) {
|
||||||
if let Ok(date) = archiver.extract_date_from_filename(filename).await {
|
if let Ok(date) = archiver.extract_date_from_filename(filename).await {
|
||||||
// Check if either Divine Worship or Afternoon Program exists for this date
|
// 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!("{}-{}",
|
let month_dir = year_dir.join(format!("{}-{}",
|
||||||
date.format("%m"),
|
date.format("%m"),
|
||||||
date.format("%B")
|
date.format("%B")
|
||||||
|
|
|
@ -4,17 +4,21 @@ use chrono::NaiveDateTime;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio::time::Duration;
|
use tokio::time::Duration;
|
||||||
|
|
||||||
pub struct LivestreamArchiver<'a> {
|
pub struct LivestreamArchiver {
|
||||||
output_path: &'a PathBuf,
|
output_path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LivestreamArchiver<'a> {
|
impl LivestreamArchiver {
|
||||||
pub fn new(output_path: &'a PathBuf) -> Self {
|
pub fn new(output_path: PathBuf) -> Self {
|
||||||
LivestreamArchiver {
|
LivestreamArchiver {
|
||||||
output_path,
|
output_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_output_path(&self) -> &PathBuf {
|
||||||
|
&self.output_path
|
||||||
|
}
|
||||||
|
|
||||||
async fn wait_for_file_ready(&self, path: &PathBuf) -> Result<()> {
|
async fn wait_for_file_ready(&self, path: &PathBuf) -> Result<()> {
|
||||||
println!("Waiting for file to be ready: {}", path.display());
|
println!("Waiting for file to be ready: {}", path.display());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue