diff options
Diffstat (limited to 'src/db/queries.rs')
| -rw-r--r-- | src/db/queries.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/db/queries.rs b/src/db/queries.rs index 62c1045..fe0518f 100644 --- a/src/db/queries.rs +++ b/src/db/queries.rs @@ -679,6 +679,24 @@ pub fn index_version(db: &Db, name: &str) -> Result<Option<String>> { }) } +/// The exact artifact we serve for a package name: `(version, digest)` of the +/// in-index row's artifact. This is what a build's lease manifest pins — the +/// dependency arrives as these bytes or the build fails closed (§8, +/// provisioning); nothing about it is re-resolved at build time. +pub fn index_artifact(db: &Db, name: &str) -> Result<Option<(String, String)>> { + db.read(|c| { + c.query_row( + "SELECT p.version, a.digest FROM package p + JOIN artifact a ON a.id = p.artifact_id + WHERE p.name=?1 AND p.state='in_index' ORDER BY p.id DESC LIMIT 1", + params![name], + |r| Ok((r.get(0)?, r.get(1)?)), + ) + .optional() + .map_err(Into::into) + }) +} + /// Is `name` one of the packages we publish? Used to filter world snapshots /// down to our own packages (§10.1). pub fn is_ours(db: &Db, name: &str) -> Result<bool> { |
