various: fix trailing commas and import ordering

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia48ceb56b9b1ce50ee01ff38d14f740c6a6a6964
This commit is contained in:
raf 2026-02-09 13:15:47 +03:00
commit b5fb382ac0
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 44 additions and 22 deletions

View file

@ -964,9 +964,10 @@ impl Config {
/// Ensure all directories needed by this config exist and are writable. /// Ensure all directories needed by this config exist and are writable.
pub fn ensure_dirs(&self) -> crate::error::Result<()> { pub fn ensure_dirs(&self) -> crate::error::Result<()> {
if let Some(ref sqlite) = self.storage.sqlite if let Some(ref sqlite) = self.storage.sqlite {
&& let Some(parent) = sqlite.path.parent() if let Some(parent) = sqlite.path.parent() {
{ // Skip if parent is empty string (happens with bare filenames like "pinakes.db")
if !parent.as_os_str().is_empty() {
std::fs::create_dir_all(parent)?; std::fs::create_dir_all(parent)?;
let metadata = std::fs::metadata(parent)?; let metadata = std::fs::metadata(parent)?;
if metadata.permissions().readonly() { if metadata.permissions().readonly() {
@ -976,6 +977,8 @@ impl Config {
))); )));
} }
} }
}
}
Ok(()) Ok(())
} }

View file

@ -1,14 +1,13 @@
use pinakes_plugin_api::{ use async_trait::async_trait;
Capabilities, EnvironmentCapability, Event, EventType,
ExtractedMetadata, FilesystemCapability, HealthStatus,
MediaTypeDefinition, NetworkCapability, Plugin, PluginContext,
PluginError, PluginMetadata, PluginResult, SearchIndexItem, SearchQuery,
SearchResult, SearchStats, ThumbnailFormat, ThumbnailInfo, ThumbnailOptions,
};
use pinakes_plugin_api::wasm::{HttpRequest, HttpResponse, LogLevel, LogMessage}; use pinakes_plugin_api::wasm::{HttpRequest, HttpResponse, LogLevel, LogMessage};
use pinakes_plugin_api::{
Capabilities, EnvironmentCapability, Event, EventType, ExtractedMetadata, FilesystemCapability,
HealthStatus, MediaTypeDefinition, NetworkCapability, Plugin, PluginContext, PluginError,
PluginMetadata, PluginResult, SearchIndexItem, SearchQuery, SearchResult, SearchStats,
ThumbnailFormat, ThumbnailInfo, ThumbnailOptions,
};
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use async_trait::async_trait;
struct TestPlugin { struct TestPlugin {
initialized: bool, initialized: bool,
@ -90,7 +89,10 @@ async fn test_plugin_context_creation() {
assert_eq!(context.data_dir, PathBuf::from("/data/test-plugin")); assert_eq!(context.data_dir, PathBuf::from("/data/test-plugin"));
assert_eq!(context.cache_dir, PathBuf::from("/cache/test-plugin")); assert_eq!(context.cache_dir, PathBuf::from("/cache/test-plugin"));
assert_eq!(context.config.get("enabled").unwrap(), &serde_json::json!(true)); assert_eq!(
context.config.get("enabled").unwrap(),
&serde_json::json!(true)
);
assert!(context.capabilities.network.enabled); assert!(context.capabilities.network.enabled);
assert_eq!( assert_eq!(
context.capabilities.max_memory_bytes, context.capabilities.max_memory_bytes,
@ -235,7 +237,11 @@ async fn test_thumbnail_options_serialization() {
#[tokio::test] #[tokio::test]
async fn test_thumbnail_format_variants() { async fn test_thumbnail_format_variants() {
for format in [ThumbnailFormat::Jpeg, ThumbnailFormat::Png, ThumbnailFormat::WebP] { for format in [
ThumbnailFormat::Jpeg,
ThumbnailFormat::Png,
ThumbnailFormat::WebP,
] {
let options = ThumbnailOptions { let options = ThumbnailOptions {
width: 100, width: 100,
height: 100, height: 100,
@ -377,7 +383,13 @@ async fn test_log_message_serialization() {
#[tokio::test] #[tokio::test]
async fn test_log_level_variants() { async fn test_log_level_variants() {
let levels = [LogLevel::Trace, LogLevel::Debug, LogLevel::Info, LogLevel::Warn, LogLevel::Error]; let levels = [
LogLevel::Trace,
LogLevel::Debug,
LogLevel::Info,
LogLevel::Warn,
LogLevel::Error,
];
for level in levels { for level in levels {
let serialized = serde_json::to_string(&level).unwrap(); let serialized = serde_json::to_string(&level).unwrap();
@ -414,7 +426,11 @@ async fn test_search_index_item_serialization() {
title: Some("Summer Vacation".to_string()), title: Some("Summer Vacation".to_string()),
description: Some("Photos from summer vacation 2023".to_string()), description: Some("Photos from summer vacation 2023".to_string()),
content: None, content: None,
tags: vec!["vacation".to_string(), "summer".to_string(), "photos".to_string()], tags: vec![
"vacation".to_string(),
"summer".to_string(),
"photos".to_string(),
],
media_type: "image/jpeg".to_string(), media_type: "image/jpeg".to_string(),
metadata: HashMap::from([ metadata: HashMap::from([
("camera".to_string(), serde_json::json!("Canon EOS R5")), ("camera".to_string(), serde_json::json!("Canon EOS R5")),
@ -449,7 +465,10 @@ async fn test_health_status_variants() {
metrics: HashMap::new(), metrics: HashMap::new(),
}; };
assert!(!unhealthy.healthy); assert!(!unhealthy.healthy);
assert_eq!(unhealthy.message, Some("Database connection failed".to_string())); assert_eq!(
unhealthy.message,
Some("Database connection failed".to_string())
);
} }
#[tokio::test] #[tokio::test]