fix(server): resolve import issues
This commit is contained in:
parent
f862df9a90
commit
0e84993afa
|
|
@ -1,4 +1,3 @@
|
||||||
use anyhow::Result;
|
|
||||||
use sqlx::{Row, QueryBuilder, Postgres};
|
use sqlx::{Row, QueryBuilder, Postgres};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ impl Database {
|
||||||
created_at: row.get("created_at"),
|
created_at: row.get("created_at"),
|
||||||
updated_at: row.get("updated_at"),
|
updated_at: row.get("updated_at"),
|
||||||
document_count: 0,
|
document_count: 0,
|
||||||
|
source_count: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if Some(doc_id) != current_doc_id {
|
if Some(doc_id) != current_doc_id {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use sqlx::{QueryBuilder, Postgres, Transaction};
|
use sqlx::{QueryBuilder, Postgres, Row};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::models::{Document, UserRole, FailedDocument};
|
use crate::models::{Document, UserRole, FailedDocument};
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
use chrono::Utc;
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use crate::models::{Document, FileInfo};
|
use crate::models::{Document, FileInfo};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use utoipa::{ToSchema, IntoParams};
|
use utoipa::{ToSchema, IntoParams};
|
||||||
|
|
||||||
use super::responses::{EnhancedDocumentResponse, SearchSnippet, HighlightRange};
|
use super::responses::EnhancedDocumentResponse;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, ToSchema, IntoParams)]
|
#[derive(Debug, Serialize, Deserialize, ToSchema, IntoParams)]
|
||||||
pub struct SearchRequest {
|
pub struct SearchRequest {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
use tokio::time::{Duration, Instant};
|
use tokio::time::{Duration, Instant};
|
||||||
use tracing::{warn, info};
|
use tracing::info;
|
||||||
|
|
||||||
/// Request throttler to limit concurrent operations
|
/// Request throttler to limit concurrent operations
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
use axum::{
|
|
||||||
routing::{get, post, delete},
|
|
||||||
Router,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use crate::AppState;
|
|
||||||
|
|
||||||
// Import all the modularized functions
|
|
||||||
mod types;
|
|
||||||
mod crud;
|
|
||||||
mod ocr;
|
|
||||||
mod bulk;
|
|
||||||
mod debug;
|
|
||||||
mod failed;
|
|
||||||
|
|
||||||
// Re-export types for external use
|
|
||||||
pub use types::*;
|
|
||||||
|
|
||||||
// Use the individual module functions
|
|
||||||
use crud::*;
|
|
||||||
use ocr::*;
|
|
||||||
use bulk::*;
|
|
||||||
use debug::*;
|
|
||||||
use failed::*;
|
|
||||||
|
|
||||||
/// Documents router with all document-related endpoints
|
|
||||||
pub fn router() -> Router<Arc<AppState>> {
|
|
||||||
Router::new()
|
|
||||||
// Basic CRUD operations
|
|
||||||
.route("/", post(upload_document))
|
|
||||||
.route("/", get(list_documents))
|
|
||||||
.route("/", delete(bulk_delete_documents))
|
|
||||||
.route("/{id}", get(get_document_by_id))
|
|
||||||
.route("/{id}", delete(delete_document))
|
|
||||||
.route("/{id}/download", get(download_document))
|
|
||||||
.route("/{id}/view", get(view_document))
|
|
||||||
|
|
||||||
// OCR operations
|
|
||||||
.route("/{id}/ocr", get(get_document_ocr))
|
|
||||||
.route("/{id}/retry-ocr", post(retry_ocr))
|
|
||||||
.route("/ocr/bulk-retry", post(crate::routes::documents_ocr_retry::bulk_retry_ocr))
|
|
||||||
.route("/ocr/retry-stats", get(crate::routes::documents_ocr_retry::get_ocr_retry_stats))
|
|
||||||
.route("/ocr/retry-recommendations", get(crate::routes::documents_ocr_retry::get_retry_recommendations))
|
|
||||||
.route("/{id}/ocr/retry-history", get(crate::routes::documents_ocr_retry::get_document_retry_history))
|
|
||||||
|
|
||||||
// Bulk operations
|
|
||||||
.route("/delete-low-confidence", post(delete_low_confidence_documents))
|
|
||||||
.route("/delete-failed-ocr", post(delete_failed_ocr_documents))
|
|
||||||
|
|
||||||
// Debug and diagnostic operations
|
|
||||||
.route("/{id}/debug", get(get_document_debug_info))
|
|
||||||
.route("/{id}/thumbnail", get(get_document_thumbnail))
|
|
||||||
.route("/{id}/processed-image", get(get_processed_image))
|
|
||||||
|
|
||||||
// Failed document management
|
|
||||||
.route("/failed", get(get_failed_documents))
|
|
||||||
.route("/failed/{id}/view", get(view_failed_document))
|
|
||||||
|
|
||||||
// Other operations
|
|
||||||
.route("/duplicates", get(get_user_duplicates))
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,7 @@ use axum::{
|
||||||
extract::State,
|
extract::State,
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
response::Json,
|
response::Json,
|
||||||
routing::{get, put},
|
routing::get,
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
use axum::{
|
|
||||||
routing::{get, post, delete, put},
|
|
||||||
Router,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use crate::AppState;
|
|
||||||
|
|
||||||
// Declare the modules
|
|
||||||
mod crud;
|
|
||||||
mod sync;
|
|
||||||
mod validation;
|
|
||||||
mod estimation;
|
|
||||||
|
|
||||||
// Import all the modularized functions
|
|
||||||
use crud::*;
|
|
||||||
use sync::*;
|
|
||||||
use validation::*;
|
|
||||||
use estimation::*;
|
|
||||||
|
|
||||||
/// Sources router with all source-related endpoints
|
|
||||||
pub fn router() -> Router<Arc<AppState>> {
|
|
||||||
Router::new()
|
|
||||||
// Basic CRUD operations
|
|
||||||
.route("/", get(list_sources).post(create_source))
|
|
||||||
.route("/{id}", get(get_source).put(update_source).delete(delete_source))
|
|
||||||
|
|
||||||
// Sync operations
|
|
||||||
.route("/{id}/sync", post(trigger_sync))
|
|
||||||
.route("/{id}/sync/stop", post(stop_sync))
|
|
||||||
.route("/{id}/deep-scan", post(trigger_deep_scan))
|
|
||||||
|
|
||||||
// Validation and testing
|
|
||||||
.route("/{id}/validate", post(validate_source))
|
|
||||||
.route("/{id}/test", post(test_connection))
|
|
||||||
.route("/test-connection", post(test_connection_with_config))
|
|
||||||
|
|
||||||
// Estimation
|
|
||||||
.route("/{id}/estimate", post(estimate_crawl))
|
|
||||||
.route("/estimate", post(estimate_crawl_with_config))
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@ use axum::{
|
||||||
extract::{Path, State},
|
extract::{Path, State},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
response::Json,
|
response::Json,
|
||||||
routing::{get, post, put, delete},
|
routing::get,
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tokio::time::interval;
|
use tokio::time::interval;
|
||||||
use tokio::sync::{Mutex, RwLock};
|
use tokio::sync::RwLock;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::{error, info, warn};
|
use tracing::{error, info, warn};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use chrono::Utc;
|
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use futures::stream::{FuturesUnordered, StreamExt};
|
use futures::stream::{FuturesUnordered, StreamExt};
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ use tracing::{error, info, warn};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::Database,
|
db::Database,
|
||||||
ocr::queue::OcrQueueService,
|
|
||||||
services::file_service::FileService,
|
|
||||||
AppState,
|
AppState,
|
||||||
};
|
};
|
||||||
use crate::services::webdav::{WebDAVConfig, WebDAVService};
|
use crate::services::webdav::{WebDAVConfig, WebDAVService};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use tracing::{info, warn, error};
|
use tracing::{info, warn, error};
|
||||||
|
|
@ -9,7 +8,7 @@ use tracing::{info, warn, error};
|
||||||
use crate::models::Document;
|
use crate::models::Document;
|
||||||
|
|
||||||
#[cfg(feature = "ocr")]
|
#[cfg(feature = "ocr")]
|
||||||
use image::{DynamicImage, ImageFormat, imageops::FilterType, Rgb, RgbImage, Rgba, ImageBuffer};
|
use image::{DynamicImage, ImageFormat, imageops::FilterType};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FileService {
|
pub struct FileService {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::DateTime;
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use sha2::{Sha256, Digest};
|
use sha2::{Sha256, Digest};
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::DateTime;
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
#[cfg(feature = "s3")]
|
#[cfg(feature = "s3")]
|
||||||
use aws_sdk_s3::Client;
|
use aws_sdk_s3::Client;
|
||||||
#[cfg(feature = "s3")]
|
#[cfg(feature = "s3")]
|
||||||
use aws_config::{BehaviorVersion, load_from_env};
|
use aws_config::load_from_env;
|
||||||
#[cfg(feature = "s3")]
|
#[cfg(feature = "s3")]
|
||||||
use aws_credential_types::Credentials;
|
use aws_credential_types::Credentials;
|
||||||
#[cfg(feature = "s3")]
|
#[cfg(feature = "s3")]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// WebDAV server configuration
|
/// WebDAV server configuration
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::Result;
|
||||||
use reqwest::Method;
|
use reqwest::Method;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
use futures_util::stream::{self, StreamExt};
|
use futures_util::stream::{self, StreamExt};
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
use crate::models::{FileInfo, WebDAVCrawlEstimate, WebDAVFolderInfo};
|
use crate::models::{FileInfo, WebDAVCrawlEstimate, WebDAVFolderInfo};
|
||||||
use crate::webdav_xml_parser::{parse_propfind_response, parse_propfind_response_with_directories};
|
use crate::webdav_xml_parser::{parse_propfind_response, parse_propfind_response_with_directories};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info};
|
||||||
|
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
FileInfo, WebDAVConnectionResult, WebDAVCrawlEstimate, WebDAVTestConnection,
|
FileInfo, WebDAVConnectionResult, WebDAVCrawlEstimate, WebDAVTestConnection,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
use super::config::WebDAVConfig;
|
use super::config::WebDAVConfig;
|
||||||
use super::connection::WebDAVConnection;
|
use super::connection::WebDAVConnection;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use tracing::{debug, info, warn, error};
|
use tracing::{info, warn, error};
|
||||||
|
|
||||||
/// Check if DEBUG environment variable is set to enable verbose debug output
|
/// Check if DEBUG environment variable is set to enable verbose debug output
|
||||||
pub fn is_debug_enabled() -> bool {
|
pub fn is_debug_enabled() -> bool {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue