feat: fix content sharing — nginx proxy, file path resolution, catalog filtering
- Add /content and /dwn proxy locations to nginx config (both HTTP and HTTPS) so peer requests reach the backend instead of the SPA catch-all - Update content_file_path() to check FileBrowser data dir as fallback when files aren't in the dedicated content/files/ directory - Populate size_bytes from actual file metadata in content.add - Filter out availability:nobody items from the public catalog endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -348,10 +348,11 @@ impl ApiHandler {
|
||||
async fn handle_content_catalog(config: &Config) -> Result<Response<hyper::Body>> {
|
||||
match content_server::load_catalog(&config.data_dir).await {
|
||||
Ok(catalog) => {
|
||||
// Only expose public metadata, not file paths
|
||||
// Only expose public metadata for available items
|
||||
let items: Vec<serde_json::Value> = catalog
|
||||
.items
|
||||
.iter()
|
||||
.filter(|i| !matches!(i.availability, content_server::Availability::Nobody))
|
||||
.map(|i| {
|
||||
serde_json::json!({
|
||||
"id": i.id,
|
||||
|
||||
@@ -31,7 +31,7 @@ impl RpcHandler {
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
let item = ContentItem {
|
||||
let mut item = ContentItem {
|
||||
id: uuid::Uuid::new_v4().to_string(),
|
||||
filename: filename.to_string(),
|
||||
mime_type: mime_type.to_string(),
|
||||
@@ -42,6 +42,12 @@ impl RpcHandler {
|
||||
added_at: chrono::Utc::now().to_rfc3339(),
|
||||
};
|
||||
|
||||
// Resolve actual file size from disk
|
||||
let file_path = content_server::content_file_path(&self.config.data_dir, &item);
|
||||
if let Ok(metadata) = std::fs::metadata(&file_path) {
|
||||
item.size_bytes = metadata.len();
|
||||
}
|
||||
|
||||
content_server::add_item(&self.config.data_dir, item.clone()).await?;
|
||||
Ok(serde_json::json!({ "item": item }))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user