Skip to content

Commit

Permalink
Prevent saving error report when no file has been processed
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomideac committed Jul 6, 2023
1 parent 314a128 commit 7458178
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fixmylib"
version = "0.2.9"
version = "0.2.10"
edition = "2021"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ services:
- VIDEO_CONVERTER_THREADS=1

# Set time to wait between new file discovery by scanner job.
- SECONDS_BETWEEN_FILE_SCANS=600
- SECONDS_BETWEEN_FILE_SCANS=3600

# Set time to wait between checks for new discovered files that haven't been processed yet.
- SECONDS_BETWEEN_PROCESSOR_RUNS=10
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ENV LOGS_FOLDER=/media-out
ENV SCANNER_THREADS=4
ENV IMAGE_CONVERTER_THREADS=4
ENV VIDEO_CONVERTER_THREADS=1
ENV SECONDS_BETWEEN_FILE_SCANS=600
ENV SECONDS_BETWEEN_FILE_SCANS=3600
ENV SECONDS_BETWEEN_PROCESSOR_RUNS=10
ENV ENABLE_THUMBNAIL_PRESET=true
ENV ENABLE_PREVIEW_PRESET=true
Expand Down
11 changes: 8 additions & 3 deletions src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl FileToBeProcessed<'_> {
pub async fn run(ctx: &AppContext) -> Result<()> {
loop {
info!("Checking for unprocessed files...");
let mut total_processed_files_count = 0;
for preset_name in get_preset_names(ctx) {
debug!("Creating jobs for preset {preset_name}");
let ticker = Ticker::new();
Expand All @@ -183,15 +184,19 @@ pub async fn run(ctx: &AppContext) -> Result<()> {
.process_pending_file_jobs(&preset_name)
.await
.expect("it should work flawless to process files");
if processed_files_count != 0 {
if processed_files_count > 0 {
ticker.elapsed(format!(
"to process unprocessed files for {preset_name} preset."
))
}
total_processed_files_count += processed_files_count
}

if total_processed_files_count > 0 {
debug!("Going to save reports...");
save_failed_jobs_report(ctx).await?;
}

debug!("Going to save reports...");
save_failed_jobs_report(ctx).await?;
sleep(Duration::from_secs(
ctx.config.seconds_between_processor_runs,
))
Expand Down

0 comments on commit 7458178

Please sign in to comment.