treewide: cleanup
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia01590cdeed872cc8ebd16f6ca95f3cc6a6a6964
This commit is contained in:
parent
0ba898c881
commit
185e3b562a
16 changed files with 258 additions and 219 deletions
|
|
@ -42,7 +42,9 @@ pub async fn export_library(
|
|||
match format {
|
||||
ExportFormat::Json => {
|
||||
let json = serde_json::to_string_pretty(&items).map_err(|e| {
|
||||
crate::error::PinakesError::Serialization(format!("json serialize: {e}"))
|
||||
crate::error::PinakesError::Serialization(format!(
|
||||
"json serialize: {e}"
|
||||
))
|
||||
})?;
|
||||
std::fs::write(destination, json)?;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ pub mod video;
|
|||
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use crate::{
|
||||
error::Result,
|
||||
media_type::MediaType,
|
||||
model::BookMetadata,
|
||||
};
|
||||
use crate::{error::Result, media_type::MediaType, model::BookMetadata};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ExtractedMetadata {
|
||||
|
|
|
|||
|
|
@ -607,42 +607,12 @@ impl PluginManager {
|
|||
pub async fn list_ui_pages(
|
||||
&self,
|
||||
) -> Vec<(String, pinakes_plugin_api::UiPage)> {
|
||||
let registry = self.registry.read().await;
|
||||
let mut pages = Vec::new();
|
||||
for plugin in registry.list_all() {
|
||||
if !plugin.enabled {
|
||||
continue;
|
||||
}
|
||||
let plugin_dir = plugin
|
||||
.manifest_path
|
||||
.as_ref()
|
||||
.and_then(|p| p.parent())
|
||||
.map(std::path::Path::to_path_buf);
|
||||
let Some(plugin_dir) = plugin_dir else {
|
||||
// No manifest path; serve only inline pages.
|
||||
for entry in &plugin.manifest.ui.pages {
|
||||
if let pinakes_plugin_api::manifest::UiPageEntry::Inline(page) = entry
|
||||
{
|
||||
pages.push((plugin.id.clone(), (**page).clone()));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
};
|
||||
match plugin.manifest.load_ui_pages(&plugin_dir) {
|
||||
Ok(loaded) => {
|
||||
for page in loaded {
|
||||
pages.push((plugin.id.clone(), page));
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
tracing::warn!(
|
||||
"Failed to load UI pages for plugin '{}': {e}",
|
||||
plugin.id
|
||||
);
|
||||
},
|
||||
}
|
||||
}
|
||||
pages
|
||||
self
|
||||
.list_ui_pages_with_endpoints()
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|(id, page, _)| (id, page))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// List all UI pages provided by loaded plugins, including each plugin's
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ impl PluginRegistry {
|
|||
self
|
||||
.plugins
|
||||
.values()
|
||||
.filter(|p| p.manifest.plugin.kind.contains(&kind.to_string()))
|
||||
.filter(|p| p.manifest.plugin.kind.iter().any(|k| k == kind))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1888,10 +1888,12 @@ impl StorageBackend for SqliteBackend {
|
|||
.unchecked_transaction()
|
||||
.map_err(crate::error::db_ctx("batch_tag_media", &ctx))?;
|
||||
// Prepare statement once for reuse
|
||||
let mut stmt = tx.prepare_cached(
|
||||
"INSERT OR IGNORE INTO media_tags (media_id, tag_id) VALUES (?1, ?2)",
|
||||
)
|
||||
.map_err(crate::error::db_ctx("batch_tag_media", &ctx))?;
|
||||
let mut stmt = tx
|
||||
.prepare_cached(
|
||||
"INSERT OR IGNORE INTO media_tags (media_id, tag_id) VALUES (?1, \
|
||||
?2)",
|
||||
)
|
||||
.map_err(crate::error::db_ctx("batch_tag_media", &ctx))?;
|
||||
let mut count = 0u64;
|
||||
for mid in &media_ids {
|
||||
for tid in &tag_ids {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue