remove old unused module
This commit is contained in:
@@ -2,4 +2,3 @@ pub mod config;
|
|||||||
pub mod domain;
|
pub mod domain;
|
||||||
pub mod inbound;
|
pub mod inbound;
|
||||||
pub mod outbound;
|
pub mod outbound;
|
||||||
pub mod warrens;
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
use sqlx::{Acquire, PgExecutor, Postgres};
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::Result;
|
|
||||||
|
|
||||||
use super::Warren;
|
|
||||||
|
|
||||||
impl Warren {
|
|
||||||
pub async fn get<'c, E>(e: E, id: &Uuid) -> Result<Self>
|
|
||||||
where
|
|
||||||
E: PgExecutor<'c> + Acquire<'c, Database = Postgres>,
|
|
||||||
{
|
|
||||||
let warren: Self = sqlx::query_as(
|
|
||||||
"
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
warrens
|
|
||||||
WHERE
|
|
||||||
id = $1
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.bind(id)
|
|
||||||
.fetch_one(e)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(warren)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn list<'c, E>(e: E) -> Result<Vec<Self>>
|
|
||||||
where
|
|
||||||
E: PgExecutor<'c> + Acquire<'c, Database = Postgres>,
|
|
||||||
{
|
|
||||||
let warren: Vec<Self> = sqlx::query_as(
|
|
||||||
"
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
warrens
|
|
||||||
LIMIT
|
|
||||||
50
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.fetch_all(e)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(warren)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/* pub mod db;
|
|
||||||
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use serde::Serialize;
|
|
||||||
use sqlx::prelude::FromRow;
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
Result,
|
|
||||||
fs::{
|
|
||||||
DirectoryEntry, FileType, create_dir, delete_dir, delete_file, get_dir_entries, write_file,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, FromRow)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct Warren {
|
|
||||||
id: Uuid,
|
|
||||||
name: String,
|
|
||||||
#[serde(skip)]
|
|
||||||
path: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Warren {
|
|
||||||
pub fn id(&self) -> &Uuid {
|
|
||||||
&self.id
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(&self) -> &str {
|
|
||||||
&self.name
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path(&self) -> &str {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Warren {
|
|
||||||
pub async fn read_path(
|
|
||||||
&self,
|
|
||||||
serve_path: &str,
|
|
||||||
path: Option<String>,
|
|
||||||
) -> Result<Vec<DirectoryEntry>> {
|
|
||||||
let path = build_path(serve_path, &self.path, path.as_deref());
|
|
||||||
|
|
||||||
get_dir_entries(path).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn create_directory(&self, serve_path: &str, path: String) -> Result<()> {
|
|
||||||
let path = build_path(serve_path, &self.path, Some(&path));
|
|
||||||
|
|
||||||
create_dir(path).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn delete_entry(
|
|
||||||
&self,
|
|
||||||
serve_path: &str,
|
|
||||||
path: String,
|
|
||||||
file_type: FileType,
|
|
||||||
) -> Result<()> {
|
|
||||||
let path = build_path(serve_path, &self.path, Some(&path));
|
|
||||||
|
|
||||||
match file_type {
|
|
||||||
FileType::File => delete_file(path).await,
|
|
||||||
FileType::Directory => delete_dir(path).await,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn upload(
|
|
||||||
&self,
|
|
||||||
serve_path: &str,
|
|
||||||
rest_path: Option<&str>,
|
|
||||||
file_name: &str,
|
|
||||||
data: &[u8],
|
|
||||||
) -> Result<()> {
|
|
||||||
let rest = format!("{}/{file_name}", rest_path.unwrap_or(""));
|
|
||||||
|
|
||||||
let path = build_path(serve_path, &self.path, Some(&rest));
|
|
||||||
|
|
||||||
write_file(path, data).await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_path(serve_path: &str, warren_path: &str, rest_path: Option<&str>) -> PathBuf {
|
|
||||||
let mut final_path = PathBuf::from(serve_path);
|
|
||||||
|
|
||||||
final_path.push(warren_path.strip_prefix("/").unwrap_or(warren_path));
|
|
||||||
|
|
||||||
if let Some(ref rest) = rest_path {
|
|
||||||
final_path.push(rest.strip_prefix("/").unwrap_or(rest));
|
|
||||||
}
|
|
||||||
|
|
||||||
final_path
|
|
||||||
} */
|
|
||||||
Reference in New Issue
Block a user