export feature

This commit is contained in:
2026-05-09 20:51:29 +02:00
parent d75db17ece
commit dda8b32e6a
57 changed files with 2245 additions and 624 deletions

View File

@@ -22,9 +22,9 @@ impl StorageConfig {
&std::env::var("POSTER_STORAGE_PATH")
.context("POSTER_STORAGE_PATH required when POSTER_STORAGE_BACKEND=local")?,
)?,
other => anyhow::bail!(
"Unknown POSTER_STORAGE_BACKEND: {other:?}. Valid values: s3, local"
),
other => {
anyhow::bail!("Unknown POSTER_STORAGE_BACKEND: {other:?}. Valid values: s3, local")
}
};
Ok(Self(store))
@@ -55,8 +55,7 @@ fn build_s3_store(
}
fn build_local_store(path: &str) -> anyhow::Result<Arc<dyn ObjectStore>> {
std::fs::create_dir_all(path)
.context("Failed to create poster storage directory")?;
std::fs::create_dir_all(path).context("Failed to create poster storage directory")?;
let store = LocalFileSystem::new_with_prefix(path)
.context("Failed to initialise local file system store")?;
Ok(Arc::new(store))
@@ -68,8 +67,7 @@ mod tests {
#[test]
fn local_store_creates_dir_and_succeeds() {
let dir = std::env::temp_dir()
.join(format!("poster_test_{}", uuid::Uuid::new_v4()));
let dir = std::env::temp_dir().join(format!("poster_test_{}", uuid::Uuid::new_v4()));
let result = build_local_store(dir.to_str().unwrap());
assert!(result.is_ok(), "expected Ok, got: {:?}", result.err());
assert!(dir.exists(), "directory should have been created");
@@ -77,8 +75,7 @@ mod tests {
#[test]
fn local_store_succeeds_if_dir_already_exists() {
let dir = std::env::temp_dir()
.join(format!("poster_test_{}", uuid::Uuid::new_v4()));
let dir = std::env::temp_dir().join(format!("poster_test_{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&dir).unwrap();
let result = build_local_store(dir.to_str().unwrap());
assert!(result.is_ok());