Skip to content

Commit

Permalink
ANE-1050 avoid rescanning unchanged tags and branches (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
spatten authored Jul 10, 2023
1 parent 2270c69 commit d0b8ffe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

## v0.2.3

Bug fix:

- Broker was not properly noting which revisions it had scanned, so it was scanning all recent tags and branches on every poll cycle. This is now fixed.

## v0.2.2

Bug fix:
Bug fix:

- Broker now copies its debug bundle (generated during `broker fix`) from the system temp location instead of renaming.
This resolves issues preventing debug bundles from being stored for Linux installations where the temporary location
Expand Down
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 = "broker"
version = "0.2.3-pre"
version = "0.2.3"
edition = "2021"
description = "The bridge between FOSSA and internal DevOps services"
readme = "README.md"
Expand Down
15 changes: 14 additions & 1 deletion src/subcommand/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ pub enum Error {
#[error("handle task")]
TaskHandle,

/// If we fail to set a task's state in the sqlite DB, this error is raised.
#[error("set task state")]
TaskSetState,

/// If we fail to mark a task complete, this error is raised.
#[error("mark task complete")]
TaskComplete,
Expand Down Expand Up @@ -241,7 +245,7 @@ async fn poll_integration<D: Database>(
// No previous state; this must be a new reference.
Ok(None) => Some(Ok(reference)),
// There was previous state, it's only new if the state is different.
// We're assuming "different state" always means "newer state".
// We're assuming "different state" always means "newer state".
// This is because state is currently expressed as a git commit string,
// which on its own doesn't have any form of ordering.
Ok(Some(db_state)) => {
Expand Down Expand Up @@ -318,6 +322,7 @@ async fn scan_git_references<D: Database>(
.await
.change_context(Error::DownloadFossaCli)
.describe("Broker relies on fossa-cli to perform analysis of your projects")?;
let db = &ctx.db;

loop {
let guard = receiver.recv().await.change_context(Error::TaskReceive)?;
Expand All @@ -331,6 +336,14 @@ async fn scan_git_references<D: Database>(
.send(&upload)
.await
.change_context(Error::TaskEnqueue)?;
let remote = job.integration.remote().to_owned();
let coordinate = job.reference.as_coordinate(&remote);
let state = job.reference.as_state();

// Mark this reference as scanned in the local DB
db.set_state(&coordinate, state)
.await
.change_context(Error::TaskSetState)?;

guard.commit().change_context(Error::TaskComplete)?;
}
Expand Down

0 comments on commit d0b8ffe

Please sign in to comment.