Skip to content

Commit 50b5847

Browse files
committed
Silently ignore duplicate jobs
1 parent e02d20b commit 50b5847

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rfd-processor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ async-trait = { workspace = true }
1010
base64 = { workspace = true }
1111
chrono = { workspace = true }
1212
config = { workspace = true }
13+
diesel = { workspace = true }
1314
google-drive3 = { workspace = true }
1415
google-storage1 = { workspace = true }
1516
hex = { workspace = true }

rfd-processor/src/scanner.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use diesel::result::{Error as DieselError, DatabaseErrorKind};
12
use rfd_model::{
23
storage::{JobStore, StoreError},
34
NewJob,
@@ -34,9 +35,16 @@ pub async fn scanner(ctx: Arc<Context>) -> Result<(), ScannerError> {
3435
match JobStore::upsert(&ctx.db.storage, update.clone().into()).await {
3536
Ok(job) => tracing::trace!(?job.id, "Added job to the queue"),
3637
Err(err) => {
37-
// TODO: Do not warn on uniqueness violations. It is expected that the scanner
38-
// picks ups redundant jobs for RFDs that have not changed since the last scan
39-
tracing::warn!(?err, ?update, "Failed to add job")
38+
match err {
39+
StoreError::Db(DieselError::DatabaseError(DatabaseErrorKind::UniqueViolation, _)) => {
40+
// Nothing to do here, we expect uniqueness conflicts. It is expected
41+
// that the scanner picks ups redundant jobs for RFDs that have not
42+
// changed since the last scan
43+
}
44+
err => {
45+
tracing::warn!(?err, ?update, "Failed to add job")
46+
}
47+
}
4048
}
4149
}
4250
}

0 commit comments

Comments
 (0)