Skip to content

Commit 0f26687

Browse files
authored
worker/jobs/downloads: Ignore log files from the index domain (#8046)
1 parent 6e81be9 commit 0f26687

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/worker/jobs/downloads.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ impl ProcessCdnLogQueue {
251251
let bucket = record.s3.bucket.name;
252252
let path = record.s3.object.key;
253253

254+
if Self::is_ignored_path(&path) {
255+
debug!("Skipping ignored path: {path}");
256+
continue;
257+
}
258+
254259
let path = match object_store::path::Path::from_url_path(&path) {
255260
Ok(path) => path,
256261
Err(err) => {
@@ -280,6 +285,10 @@ impl ProcessCdnLogQueue {
280285

281286
Ok(())
282287
}
288+
289+
fn is_ignored_path(path: &str) -> bool {
290+
path.contains("/index.staging.crates.io/") || path.contains("/index.crates.io/")
291+
}
283292
}
284293

285294
#[cfg(test)]
@@ -467,6 +476,29 @@ mod tests {
467476
assert_snapshot!(open_jobs(&mut test_database.connect()), @"");
468477
}
469478

479+
#[test]
480+
fn test_ignored_path() {
481+
let is_ignored = ProcessCdnLogQueue::is_ignored_path;
482+
483+
let valid_paths = vec![
484+
"cloudfront/static.crates.io/EJED5RT0WA7HA.2024-02-01-10.6a8be093.gz",
485+
"cloudfront/static.staging.crates.io/E6OCLKYH9FE8V.2024-02-01-10.5da9e90c.gz",
486+
"fastly-requests/static.crates.io/2024-02-01T09:00:00.000-4AIwSEQyIFDSzdAT1Fqt.log.zst",
487+
"fastly-requests/static.staging.crates.io/2024-02-01T09:00:00.000-QPF3Ea8eICqLkzaoC_Wt.log.zst"
488+
];
489+
for path in valid_paths {
490+
assert!(!is_ignored(path));
491+
}
492+
493+
let ignored_paths = vec![
494+
"cloudfront/index.crates.io/EUGCXGQIH3GQ3.2024-02-01-10.2e068fc2.gz",
495+
"cloudfront/index.staging.crates.io/E35K556QRQDZXW.2024-02-01-10.900ddeaf.gz",
496+
];
497+
for path in ignored_paths {
498+
assert!(is_ignored(path));
499+
}
500+
}
501+
470502
fn record_deleted_handles(queue: &mut MockSqsQueue) -> Arc<Mutex<Vec<String>>> {
471503
let deleted_handles = Arc::new(Mutex::new(vec![]));
472504

0 commit comments

Comments
 (0)