Skip to content
Snippets Groups Projects
Commit 56802713 authored by Brian Lewis's avatar Brian Lewis
Browse files

Merge branch 'drs-specs' into 'main'

Ingest different DRS formats

See merge request !2
parents aec6a879 1df72409
No related branches found
No related tags found
1 merge request!2Ingest different DRS formats
Pipeline #19120 passed
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
use std::{
env::current_dir,
io,
path::{Component, Path, PathBuf},
};
/// Resolves `.` and `..` in a path to a fully qualified path without resolving symlinks. This also will check if the
/// path is already fully qualified and if not, will prepend the path with the current directory (using
/// [`std::env::current_dir`]).
///
/// The majority of this function is copied from
/// [cargo](https://github.com/rust-lang/cargo/blob/6d6dd9d9be9c91390da620adf43581619c2fa90e/crates/cargo-util/src/paths.rs#L81)
///
/// There is currently an unstable function that does some of what this tries to do which is worth keeping an eye on:
/// <https://github.com/rust-lang/rust/issues/92750>
pub(super) fn absolute(path: &Path) -> Result<PathBuf, io::Error> {
let path = if !path.has_root() {
let root = current_dir()?;
root.join(path)
} else {
path.to_owned()
};
let mut components = path.components().peekable();
let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() {
components.next();
PathBuf::from(c.as_os_str())
} else {
PathBuf::new()
};
for component in components {
match component {
Component::Prefix(..) => unreachable!(),
Component::RootDir => {
ret.push(component.as_os_str());
}
Component::CurDir => {}
Component::ParentDir => {
ret.pop();
}
Component::Normal(c) => {
ret.push(c);
}
}
}
Ok(ret)
}
......@@ -21,7 +21,7 @@ pub enum Error {
}
/// Searches Solr for drs file metadata.
pub async fn search<'d>(drs_conf: &'d Config, solr: &Solr) -> Result<Vec<Metadata<'d>>, Error> {
pub async fn search(drs_conf: &Config, solr: &Solr) -> Result<Vec<Metadata>, Error> {
let facets = HashMap::new();
let mut start = 0;
......
......@@ -8,8 +8,6 @@ use serde::Deserialize;
use thiserror::Error;
use tracing::debug;
use crate::drs::Metadata;
const DEFAULT_PORT: u16 = 8983;
const DEFAULT_PROTOCOL: &str = "http";
......@@ -111,10 +109,10 @@ impl Solr {
}
/// Uploads `documents` into `collection` in Solr.
pub async fn update<'a>(
pub async fn update(
&self,
collection: &str,
documents: &[&Metadata<'a>],
documents: &[HashMap<&str, String>],
) -> Result<(), SolrError> {
let url = self.url(collection, "update/json/docs")?;
debug!("{}", url);
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment