Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat: verify there are no unprocessed broker events in the db
Lars Wirzenius committed 1 year ago
commit d44877da78f02c9e742acc8ebe5a0f9c80afabef
parent 31e930aecfdab902f2d5b6829bf1105b8344a7e8
1 file changed +10 -1
modified src/bin/cib.rs
@@ -69,7 +69,13 @@ impl Args {
    }

    fn open_db(&self, config: &Config) -> Result<Db, CibError> {
-
        Db::new(&config.db).map_err(CibError::db)
+
        let db = Db::new(&config.db).map_err(CibError::db)?;
+
        let events = db.queued_events().map_err(CibError::Db)?;
+
        if events.is_empty() {
+
            Ok(db)
+
        } else {
+
            Err(CibError::UnprocessedBrokerEvents)
+
        }
    }
}

@@ -260,6 +266,9 @@ enum CibError {
    #[error("failed to use SQLite database")]
    Db(#[source] DbError),

+
    #[error("database has unprocessed broker events")]
+
    UnprocessedBrokerEvents,
+

    #[error("failed create broker data type")]
    NewBroker(#[source] BrokerError),