summaryrefslogtreecommitdiffstats
path: root/src/watch/digests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch/digests.rs')
-rw-r--r--src/watch/digests.rs31
1 files changed, 1 insertions, 30 deletions
diff --git a/src/watch/digests.rs b/src/watch/digests.rs
index cb7bdbc..c67d60e 100644
--- a/src/watch/digests.rs
+++ b/src/watch/digests.rs
@@ -13,23 +13,9 @@
use crate::config::Config;
use crate::db::{self, *};
use crate::error::Result;
+use crate::recipe::{declared_sums, is_hex_digest, SKIP};
use crate::watch::mirror::Tree;
-const SKIP: &str = "SKIP";
-
-fn declared_sums(recipe: &Recipe, index: usize) -> Option<String> {
- recipe
- .sha256sums
- .get(index)
- .or_else(|| recipe.b2sums.get(index))
- .map(|s| s.trim().to_string())
- .filter(|s| !s.is_empty())
-}
-
-fn is_hex_digest(s: &str) -> bool {
- (s.len() == 64 || s.len() == 128) && s.chars().all(|c| c.is_ascii_hexdigit())
-}
-
/// Resolve the digest of every `source=()` entry.
pub fn resolve_sources(
cfg: &Config,
@@ -157,18 +143,3 @@ pub fn cached_path(db: &Db, url: &str, digest: &str) -> Option<std::path::PathBu
.map(std::path::PathBuf::from)
.filter(|p| p.exists())
}
-
-/// True when a `SKIP` on a non-VCS source means the recipe permanently refuses
-/// to verify its input — itself a risk signal (§5.3).
-pub fn skip_on_non_vcs(recipe: &Recipe) -> Vec<usize> {
- recipe
- .source_entries
- .iter()
- .filter(|e| !e.is_vcs())
- .filter(|e| match declared_sums(recipe, e.index) {
- Some(d) => d == SKIP || !is_hex_digest(&d),
- None => true,
- })
- .map(|e| e.index)
- .collect()
-}