aboutsummaryrefslogtreecommitdiff
path: root/import/src
diff options
context:
space:
mode:
Diffstat (limited to 'import/src')
-rw-r--r--import/src/db.rs7
-rw-r--r--import/src/lib.rs21
-rw-r--r--import/src/trakt.rs2
3 files changed, 15 insertions, 15 deletions
diff --git a/import/src/db.rs b/import/src/db.rs
index 87350ac..7a3636c 100644
--- a/import/src/db.rs
+++ b/import/src/db.rs
@@ -62,7 +62,7 @@ impl ImportStorage for DatabaseStorage<'_> {
Ok(value.value().0)
}
fn insert_complete_node(&self, id: &str, node: Node) -> anyhow::Result<()> {
- insert_complete_node(&self.db, id, node)
+ insert_complete_node(self.db, id, node)
}
fn add_partial_node(&self, id: &str, index_path: &[usize], node: Node) -> anyhow::Result<()> {
@@ -106,9 +106,10 @@ impl ImportStorage for DatabaseStorage<'_> {
}
}
+pub type Parts = RwLock<HashMap<String, Vec<(Vec<usize>, Node)>>>;
pub(crate) struct MemoryStorage<'a> {
pub db: &'a DataAcid,
- pub parts: RwLock<HashMap<String, Vec<(Vec<usize>, Node)>>>,
+ pub parts: Parts,
}
impl<'a> MemoryStorage<'a> {
pub fn new(db: &'a DataAcid) -> Self {
@@ -148,7 +149,7 @@ impl ImportStorage for MemoryStorage<'_> {
.to_owned())
}
fn insert_complete_node(&self, id: &str, node: Node) -> anyhow::Result<()> {
- insert_complete_node(&self.db, id, node)
+ insert_complete_node(self.db, id, node)
}
fn add_partial_node(&self, id: &str, index_path: &[usize], node: Node) -> anyhow::Result<()> {
diff --git a/import/src/lib.rs b/import/src/lib.rs
index 49f709a..544937c 100644
--- a/import/src/lib.rs
+++ b/import/src/lib.rs
@@ -3,7 +3,6 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2024 metamuffin <metamuffin.org>
*/
-#![feature(lazy_cell)]
pub mod db;
pub mod infojson;
pub mod tmdb;
@@ -60,7 +59,7 @@ struct Apis {
}
pub fn is_importing() -> bool {
- IMPORT_SEM.available_permits() <= 0
+ IMPORT_SEM.available_permits() == 0
}
pub async fn import(db: &DataAcid, fed: &Federation) -> anyhow::Result<()> {
@@ -214,8 +213,8 @@ async fn import_path(
.read_dir()?
.map(Result::unwrap)
.filter_map(|e| {
- if e.path().extension() == Some(&OsStr::new("yaml"))
- || e.path().extension() == Some(&OsStr::new("jelly"))
+ if e.path().extension() == Some(OsStr::new("yaml"))
+ || e.path().extension() == Some(OsStr::new("jelly"))
|| e.metadata().unwrap().is_dir()
{
Some(e.path())
@@ -345,12 +344,12 @@ async fn process_source(
}
}
// TODO lazy assets
- for (_, ps) in &mut node_ext.people {
+ for ps in node_ext.people.values_mut() {
for p in ps {
if let Some(id) = p.person.ids.tmdb {
if let Some(tmdb) = &ap.tmdb {
let k = tmdb.person_image(id).await?;
- if let Some(prof) = k.profiles.get(0) {
+ if let Some(prof) = k.profiles.first() {
p.person.headshot = Some(
AssetInner::Cache(tmdb.image(&prof.file_path).await?).ser(),
);
@@ -402,10 +401,10 @@ async fn process_source(
// TODO lazy assets
if let Some(poster) = &details.poster_path {
- node.public.poster = Some(AssetInner::Cache(tmdb.image(&poster).await?).ser());
+ node.public.poster = Some(AssetInner::Cache(tmdb.image(poster).await?).ser());
}
if let Some(backdrop) = &details.backdrop_path {
- node.public.backdrop = Some(AssetInner::Cache(tmdb.image(&backdrop).await?).ser());
+ node.public.backdrop = Some(AssetInner::Cache(tmdb.image(backdrop).await?).ser());
}
node.public.tagline = details.tagline.clone();
@@ -584,7 +583,7 @@ async fn process_source(
.map(|e| e.path())
.filter(|e| {
e.extension() == Some(OsStr::new("yaml"))
- || e.extension() == Some(&OsStr::new("jelly"))
+ || e.extension() == Some(OsStr::new("jelly"))
});
let mut children = Vec::new();
@@ -614,7 +613,7 @@ async fn process_source(
Ok(errors)
}
-const RE_YOUTUBE_ID: LazyLock<Regex> =
+static RE_YOUTUBE_ID: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r#"\[([A-Za-z0-9_-]{11})\]"#).unwrap());
pub fn infer_id_from_path(path: &Path) -> anyhow::Result<String> {
@@ -792,7 +791,7 @@ async fn import_remote(
};
make_opt_asset_federated(host, &mut node.public.backdrop)?;
make_opt_asset_federated(host, &mut node.public.poster)?;
- for (_, g) in &mut node_ext.people {
+ for g in node_ext.people.values_mut() {
for a in g {
make_opt_asset_federated(host, &mut a.person.headshot)?;
}
diff --git a/import/src/trakt.rs b/import/src/trakt.rs
index 2bcf45f..19c50bc 100644
--- a/import/src/trakt.rs
+++ b/import/src/trakt.rs
@@ -269,7 +269,7 @@ impl Display for TraktSearchResult {
"{} ({}) \x1b[2m{} [{}]\x1b[0m",
self.inner.inner().title,
self.inner.inner().year.unwrap_or(0),
- self.r#type.to_string(),
+ self.r#type,
self.inner.inner().ids
))
}