summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKornel <kornel@geekhood.net>2020-03-05 00:43:34 +0000
committerKornel <kornel@geekhood.net>2020-03-05 00:43:55 +0000
commit9c75129ab9f0b3d1fc7c976855116067a71c511f (patch)
tree6c24009d214b99d2a56259bdab976a10a72e8515
parent90b6a328ae2571ec27db4c96a7f6f7f0ac1b2799 (diff)
Don't re-reindex failing crates non-stop
-rw-r--r--crate_db/src/lib_crate_db.rs10
-rw-r--r--kitchen_sink/src/lib_kitchen_sink.rs1
2 files changed, 11 insertions, 0 deletions
diff --git a/crate_db/src/lib_crate_db.rs b/crate_db/src/lib_crate_db.rs
index 999dbfe..6d7e4d3 100644
--- a/crate_db/src/lib_crate_db.rs
+++ b/crate_db/src/lib_crate_db.rs
@@ -228,6 +228,16 @@ impl CrateDb {
}).await
}
+ pub async fn before_index_latest(&self, origin: &Origin) -> FResult<()> {
+ self.with_write("before_index_latest", |tx| {
+ let next_timestamp = (Utc::now().timestamp() + 3600 * 24 * 3) as u32;
+ let mut mark_updated = tx.prepare_cached("UPDATE crates SET next_update = ?2 WHERE origin = ?1")?;
+ let args: &[&dyn ToSql] = &[&origin.to_str(), &next_timestamp];
+ mark_updated.execute(args).context("premark updated crate")?;
+ Ok(())
+ }).await
+ }
+
/// Add data of the latest version of a crate to the index
/// Score is a ranking of a crate (0 = bad, 1 = great)
pub async fn index_latest(&self, c: CrateVersionData<'_>) -> FResult<()> {
diff --git a/kitchen_sink/src/lib_kitchen_sink.rs b/kitchen_sink/src/lib_kitchen_sink.rs
index ea9ce45..e7c39ed 100644
--- a/kitchen_sink/src/lib_kitchen_sink.rs
+++ b/kitchen_sink/src/lib_kitchen_sink.rs
@@ -1349,6 +1349,7 @@ impl KitchenSink {
pub async fn index_crate_highest_version(&self, origin: &Origin) -> CResult<()> {
if stopped() {Err(KitchenSinkErr::Stopped)?;}
+ self.crate_db.before_index_latest(origin).await?;
let (src, manifest, _warn) = match origin {
Origin::CratesIo(ref name) => {