Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 99 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ askama = "0.16"
askama_web = { version = "0.16", features = ["axum-0.8"] }
axum = { version = "0.8.9", features = ["macros"] }
axum-extra = { version = "0.12.6", features = ["cookie"] }
axum_typed_multipart = { version = "0.16.5", default-features = false }
# UTF-8 paths for easier String/PathBuf interop
camino = { version = "1.2.2", features = ["serde1"] }
# Date/time management
Expand All @@ -36,7 +37,7 @@ env_logger = "0.11.10"
# Interactions with the torrent client
# Comment/uncomment below for development version
# hightorrent_api = { path = "../hightorrent_api" }
hightorrent_api = { git = "https://github.com/angrynode/hightorrent_api" }
hightorrent_api = { git = "https://github.com/angrynode/hightorrent_api", branch = "feat-sea-orm", features = [ "sea_orm" ] }
# hightorrent_api = "0.2"
log = "0.4.29"
# SQLite ORM
Expand All @@ -47,6 +48,7 @@ sea-orm-migration = { version = "2.0.0-rc.38" }
serde = { version = "1.0.228", features = ["derive", "rc"] }
# (De)serialization for operations log
serde_json = { version = "1" }
serde_with = "3.20.0"
# Error declaration/context
snafu = "0.9"
# Serve static assets directly from the binary
Expand Down
4 changes: 3 additions & 1 deletion src/database/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use snafu::prelude::*;
use std::str::FromStr;

use crate::database::operator::DatabaseOperator;
use crate::database::{content_folder, operation::*};
use crate::database::{content_folder, operation::*, torrent};
use crate::extractors::normalized_path::*;
use crate::extractors::user::User;
use crate::routes::category::CategoryForm;
Expand All @@ -29,6 +29,8 @@ pub struct Model {
pub path: NormalizedPathAbsolute,
#[sea_orm(has_many)]
pub content_folders: HasMany<content_folder::Entity>,
#[sea_orm(has_many)]
pub torrents: HasMany<torrent::Entity>,
}

#[async_trait::async_trait]
Expand Down
3 changes: 3 additions & 0 deletions src/database/content_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::str::FromStr;
use crate::database::category::{self, CategoryError};
use crate::database::operation::{Operation, OperationId, OperationLog, OperationType, Table};
use crate::database::operator::DatabaseOperator;
use crate::database::torrent;
use crate::extractors::normalized_path::{NormalizedPathAbsolute, NormalizedPathComponent};
use crate::extractors::user::User;
use crate::routes::content_folder::ContentFolderForm;
Expand Down Expand Up @@ -43,6 +44,8 @@ pub struct Model {
pub parent_id: Option<i32>,
#[sea_orm(self_ref, relation_enum = "Parent", from = "parent_id", to = "id")]
pub parent: HasOne<Entity>,
#[sea_orm(has_many)]
pub torrents: HasMany<torrent::Entity>,
}

#[async_trait::async_trait]
Expand Down
1 change: 1 addition & 0 deletions src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pub mod category;
pub mod content_folder;
pub mod operation;
pub mod operator;
pub mod torrent;
8 changes: 8 additions & 0 deletions src/database/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
use crate::extractors::user::User;
use crate::routes::category::CategoryForm;
use crate::routes::content_folder::ContentFolderForm;
use crate::routes::torrent::TorrentForm;

/// Type of operation applied to the database.
#[derive(Clone, Debug, Display, Serialize, Deserialize)]
Expand All @@ -24,6 +25,7 @@ pub struct OperationId {
pub enum Table {
Category,
ContentFolder,
Torrent,
}

/// Operation applied to the database.
Expand All @@ -34,6 +36,12 @@ pub enum Table {
pub enum Operation {
Category(CategoryForm),
ContentFolder(ContentFolderForm),
Torrent(TorrentForm),
MoveTorrent {
torrent: i32,
category: i32,
content_folder: Option<i32>,
},
}

impl std::fmt::Display for Operation {
Expand Down
11 changes: 10 additions & 1 deletion src/database/operator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::database::{category::CategoryOperator, content_folder::ContentFolderOperator};
use crate::database::{
category::CategoryOperator, content_folder::ContentFolderOperator, torrent::TorrentOperator,
};
use crate::extractors::user::User;
use crate::state::AppState;

Expand Down Expand Up @@ -26,4 +28,11 @@ impl DatabaseOperator {
user: self.user.clone(),
}
}

pub fn torrent(&self) -> TorrentOperator {
TorrentOperator {
state: self.state.clone(),
user: self.user.clone(),
}
}
}
Loading
Loading