fix several bugs
This commit is contained in:
@@ -210,7 +210,7 @@ impl WebDavAdapter {
|
||||
files: &[FileDto],
|
||||
subfolders: &[FolderDto],
|
||||
request: &PropFindRequest,
|
||||
depth: &str,
|
||||
_depth: &str,
|
||||
base_href: &str,
|
||||
) -> Result<()> {
|
||||
let mut xml_writer = Writer::new(writer);
|
||||
@@ -226,7 +226,7 @@ impl WebDavAdapter {
|
||||
}
|
||||
|
||||
// If depth allows, add responses for files and subfolders
|
||||
if depth != "0" {
|
||||
if _depth != "0" {
|
||||
// Add responses for files
|
||||
for file in files {
|
||||
Self::write_file_response(&mut xml_writer, file, request, &format!("{}{}", base_href, file.name))?;
|
||||
@@ -249,7 +249,7 @@ impl WebDavAdapter {
|
||||
writer: W,
|
||||
file: &FileDto,
|
||||
request: &PropFindRequest,
|
||||
depth: &str,
|
||||
_depth: &str,
|
||||
href: &str,
|
||||
) -> Result<()> {
|
||||
let mut xml_writer = Writer::new(writer);
|
||||
|
||||
@@ -38,7 +38,7 @@ impl FavoritesUseCase for FavoritesService {
|
||||
item_type as "item_type",
|
||||
created_at as "created_at"
|
||||
FROM auth.user_favorites
|
||||
WHERE user_id = $1
|
||||
WHERE user_id = $1::TEXT
|
||||
ORDER BY created_at DESC
|
||||
"#
|
||||
)
|
||||
@@ -90,7 +90,7 @@ impl FavoritesUseCase for FavoritesService {
|
||||
sqlx::query(
|
||||
r#"
|
||||
INSERT INTO auth.user_favorites (user_id, item_id, item_type)
|
||||
VALUES ($1, $2, $3)
|
||||
VALUES ($1::TEXT, $2, $3)
|
||||
ON CONFLICT (user_id, item_id, item_type) DO NOTHING
|
||||
"#
|
||||
)
|
||||
@@ -123,7 +123,7 @@ impl FavoritesUseCase for FavoritesService {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
DELETE FROM auth.user_favorites
|
||||
WHERE user_id = $1 AND item_id = $2 AND item_type = $3
|
||||
WHERE user_id = $1::TEXT AND item_id = $2 AND item_type = $3
|
||||
"#
|
||||
)
|
||||
.bind(user_uuid)
|
||||
@@ -164,7 +164,7 @@ impl FavoritesUseCase for FavoritesService {
|
||||
r#"
|
||||
SELECT EXISTS (
|
||||
SELECT 1 FROM auth.user_favorites
|
||||
WHERE user_id = $1 AND item_id = $2 AND item_type = $3
|
||||
WHERE user_id = $1::TEXT AND item_id = $2 AND item_type = $3
|
||||
) AS "is_favorite"
|
||||
"#
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ impl RecentItemsUseCase for RecentService {
|
||||
item_type as "item_type",
|
||||
accessed_at as "accessed_at"
|
||||
FROM auth.user_recent_files
|
||||
WHERE user_id = $1
|
||||
WHERE user_id = $1::TEXT
|
||||
ORDER BY accessed_at DESC
|
||||
LIMIT $2
|
||||
"#
|
||||
@@ -99,7 +99,7 @@ impl RecentItemsUseCase for RecentService {
|
||||
sqlx::query(
|
||||
r#"
|
||||
INSERT INTO auth.user_recent_files (user_id, item_id, item_type, accessed_at)
|
||||
VALUES ($1, $2, $3, CURRENT_TIMESTAMP)
|
||||
VALUES ($1::TEXT, $2, $3, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT (user_id, item_id, item_type)
|
||||
DO UPDATE SET accessed_at = CURRENT_TIMESTAMP
|
||||
"#
|
||||
@@ -136,7 +136,7 @@ impl RecentItemsUseCase for RecentService {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
DELETE FROM auth.user_recent_files
|
||||
WHERE user_id = $1 AND item_id = $2 AND item_type = $3
|
||||
WHERE user_id = $1::TEXT AND item_id = $2 AND item_type = $3
|
||||
"#
|
||||
)
|
||||
.bind(user_uuid)
|
||||
@@ -176,7 +176,7 @@ impl RecentItemsUseCase for RecentService {
|
||||
sqlx::query(
|
||||
r#"
|
||||
DELETE FROM auth.user_recent_files
|
||||
WHERE user_id = $1
|
||||
WHERE user_id = $1::TEXT
|
||||
"#
|
||||
)
|
||||
.bind(user_uuid)
|
||||
@@ -208,7 +208,7 @@ impl RecentService {
|
||||
DELETE FROM auth.user_recent_files
|
||||
WHERE id IN (
|
||||
SELECT id FROM auth.user_recent_files
|
||||
WHERE user_id = $1
|
||||
WHERE user_id = $1::TEXT
|
||||
ORDER BY accessed_at DESC
|
||||
OFFSET $2
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::domain::repositories::file_repository::{
|
||||
FileRepository, FileRepositoryError, FileRepositoryResult
|
||||
};
|
||||
use crate::application::services::storage_mediator::StorageMediator;
|
||||
use crate::application::ports::outbound::IdMappingPort;
|
||||
// use crate::application::ports::outbound::IdMappingPort;
|
||||
use crate::infrastructure::services::id_mapping_service::IdMappingError;
|
||||
use crate::infrastructure::services::file_metadata_cache::{FileMetadataCache, CacheEntryType};
|
||||
use crate::domain::services::path_service::{StoragePath, PathService};
|
||||
|
||||
@@ -4,7 +4,7 @@ use async_trait::async_trait;
|
||||
|
||||
use crate::domain::services::path_service::{PathService, StoragePath};
|
||||
use crate::application::services::storage_mediator::StorageMediator;
|
||||
use crate::application::ports::outbound::IdMappingPort;
|
||||
// use crate::application::ports::outbound::IdMappingPort;
|
||||
use crate::domain::repositories::file_repository::FileRepositoryError;
|
||||
use crate::common::errors::DomainError;
|
||||
use crate::application::ports::storage_ports::FilePathResolutionPort;
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::domain::repositories::folder_repository::{
|
||||
FolderRepository, FolderRepositoryError, FolderRepositoryResult
|
||||
};
|
||||
use crate::domain::services::path_service::{StoragePath, PathService};
|
||||
use crate::application::ports::outbound::IdMappingPort;
|
||||
// use crate::application::ports::outbound::IdMappingPort;
|
||||
use crate::infrastructure::services::id_mapping_service::{IdMappingService, IdMappingError};
|
||||
use crate::application::services::storage_mediator::StorageMediator;
|
||||
use crate::application::ports::outbound::FolderStoragePort;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use async_trait::async_trait;
|
||||
use sqlx::{PgPool, Row, Executor};
|
||||
use sqlx::{PgPool, Row};
|
||||
use std::sync::Arc;
|
||||
use chrono::Utc;
|
||||
use futures::future::BoxFuture;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use async_trait::async_trait;
|
||||
use sqlx::{PgPool, Row, Executor};
|
||||
use sqlx::{PgPool, Row};
|
||||
use std::sync::Arc;
|
||||
use futures::future::BoxFuture;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use axum::{
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
use futures::Stream;
|
||||
use futures::StreamExt;
|
||||
// use futures::StreamExt;
|
||||
use std::task::{Context, Poll};
|
||||
use std::pin::Pin;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use axum::Json;
|
||||
use serde_json::json;
|
||||
use tracing::{debug, error, instrument};
|
||||
|
||||
use crate::application::ports::trash_ports::TrashUseCase;
|
||||
// use crate::application::ports::trash_ports::TrashUseCase;
|
||||
use crate::common::di::AppState;
|
||||
use crate::interfaces::middleware::auth::AuthUser;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ use axum::{
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
use http_body_util::BodyExt;
|
||||
use chrono::Utc;
|
||||
use bytes::Buf;
|
||||
|
||||
@@ -28,7 +27,7 @@ use crate::common::errors::AppError;
|
||||
// Create a custom DAV header since it's not in the standard headers
|
||||
const HEADER_DAV: HeaderName = HeaderName::from_static("dav");
|
||||
const HEADER_LOCK_TOKEN: HeaderName = HeaderName::from_static("lock-token");
|
||||
const HEADER_IF: HeaderName = HeaderName::from_static("if");
|
||||
// const HEADER_IF: HeaderName = HeaderName::from_static("if");
|
||||
|
||||
/**
|
||||
* Creates and returns the WebDAV router with all required endpoints.
|
||||
@@ -81,7 +80,7 @@ async fn handle_options(
|
||||
) -> Result<Response<Body>, AppError> {
|
||||
// Extract State and Path from request
|
||||
let parts = req.uri().path().split('/').collect::<Vec<&str>>();
|
||||
let path = if parts.len() > 2 {
|
||||
let _path = if parts.len() > 2 {
|
||||
parts[2..].join("/")
|
||||
} else {
|
||||
"".to_string()
|
||||
@@ -313,10 +312,10 @@ async fn handle_proppatch(
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
let state = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
let _state = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
AppError::internal_error("Missing AppState extension")
|
||||
})?;
|
||||
let user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
let _user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
AppError::unauthorized("Authentication required")
|
||||
})?;
|
||||
|
||||
@@ -391,7 +390,7 @@ async fn handle_get(
|
||||
let state = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
AppError::internal_error("Missing AppState extension")
|
||||
})?;
|
||||
let user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
let _user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
AppError::unauthorized("Authentication required")
|
||||
})?;
|
||||
|
||||
@@ -405,7 +404,7 @@ async fn handle_get(
|
||||
}
|
||||
|
||||
// Get file metadata
|
||||
let file = file_service.get_file_by_path(&path).await.map_err(|e| {
|
||||
let file = file_service.get_file_by_path(&path).await.map_err(|_e| {
|
||||
AppError::not_found(format!("File not found: {}", path))
|
||||
})?;
|
||||
|
||||
@@ -654,7 +653,7 @@ async fn handle_delete(
|
||||
let state = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
AppError::internal_error("Missing AppState extension")
|
||||
})?;
|
||||
let user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
let _user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
AppError::unauthorized("Authentication required")
|
||||
})?;
|
||||
|
||||
@@ -677,7 +676,7 @@ async fn handle_delete(
|
||||
})?;
|
||||
} else {
|
||||
// Try to delete file
|
||||
let file = file_service.get_file_by_path(&path).await.map_err(|e| {
|
||||
let file = file_service.get_file_by_path(&path).await.map_err(|_e| {
|
||||
AppError::not_found(format!("Resource not found: {}", path))
|
||||
})?;
|
||||
|
||||
@@ -718,7 +717,7 @@ async fn handle_move(
|
||||
let state = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
AppError::internal_error("Missing AppState extension")
|
||||
})?;
|
||||
let user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
let _user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
AppError::unauthorized("Authentication required")
|
||||
})?;
|
||||
|
||||
@@ -779,7 +778,7 @@ async fn handle_move(
|
||||
}
|
||||
} else {
|
||||
// Try to move file
|
||||
let file = file_service.get_file_by_path(&source_path).await.map_err(|e| {
|
||||
let file = file_service.get_file_by_path(&source_path).await.map_err(|_e| {
|
||||
AppError::not_found(format!("Resource not found: {}", source_path))
|
||||
})?;
|
||||
|
||||
@@ -826,7 +825,7 @@ async fn handle_copy(
|
||||
let state = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
AppError::internal_error("Missing AppState extension")
|
||||
})?;
|
||||
let user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
let _user = req.extensions().get::<CurrentUser>().ok_or_else(|| {
|
||||
AppError::unauthorized("Authentication required")
|
||||
})?;
|
||||
|
||||
@@ -884,7 +883,7 @@ async fn handle_copy(
|
||||
}
|
||||
};
|
||||
|
||||
let new_folder = folder_service.create_folder(create_dto).await.map_err(|e| {
|
||||
let _new_folder = folder_service.create_folder(create_dto).await.map_err(|e| {
|
||||
AppError::internal_error(format!("Failed to create destination folder: {}", e))
|
||||
})?;
|
||||
|
||||
@@ -908,7 +907,7 @@ async fn handle_copy(
|
||||
}
|
||||
} else {
|
||||
// Try to copy file
|
||||
let file = file_service.get_file_by_path(&source_path).await.map_err(|e| {
|
||||
let file = file_service.get_file_by_path(&source_path).await.map_err(|_e| {
|
||||
AppError::not_found(format!("Resource not found: {}", source_path))
|
||||
})?;
|
||||
|
||||
@@ -964,7 +963,7 @@ async fn handle_lock(
|
||||
};
|
||||
|
||||
// Get the state and user in a way that doesn't keep req borrowed
|
||||
let state = {
|
||||
let _state = {
|
||||
let state_ref = req.extensions().get::<Arc<AppState>>().ok_or_else(|| {
|
||||
AppError::internal_error("Missing AppState extension")
|
||||
})?;
|
||||
@@ -1104,7 +1103,7 @@ async fn handle_unlock(
|
||||
) -> Result<Response<Body>, AppError> {
|
||||
// Clone all necessary data first to avoid borrow issues
|
||||
let uri = req.uri().clone();
|
||||
let path = {
|
||||
let _path = {
|
||||
let parts = uri.path().split('/').collect::<Vec<&str>>();
|
||||
if parts.len() > 2 {
|
||||
parts[2..].join("/")
|
||||
@@ -1135,7 +1134,7 @@ async fn handle_unlock(
|
||||
.ok_or_else(|| AppError::bad_request("Lock-Token header required"))?;
|
||||
|
||||
// Extract token from header value (format: <token>)
|
||||
let token = lock_token
|
||||
let _token = lock_token
|
||||
.trim()
|
||||
.trim_start_matches('<')
|
||||
.trim_end_matches('>')
|
||||
|
||||
Reference in New Issue
Block a user