Skip to content

Commit 24defbf

Browse files
committed
feat: Start torrent upload
1 parent da0d5b8 commit 24defbf

20 files changed

Lines changed: 679 additions & 10 deletions

Cargo.lock

Lines changed: 108 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ askama = "0.16"
1717
askama_web = { version = "0.16", features = ["axum-0.8"] }
1818
axum = { version = "0.8.9", features = ["macros"] }
1919
axum-extra = { version = "0.12.6", features = ["cookie"] }
20+
axum_typed_multipart = { version = "0.16.5", default-features = false }
2021
# UTF-8 paths for easier String/PathBuf interop
2122
camino = { version = "1.2.2", features = ["serde1"] }
2223
# Date/time management
@@ -36,7 +37,7 @@ env_logger = "0.11.10"
3637
# Interactions with the torrent client
3738
# Comment/uncomment below for development version
3839
# hightorrent_api = { path = "../hightorrent_api" }
39-
hightorrent_api = { git = "https://github.com/angrynode/hightorrent_api" }
40+
hightorrent_api = { git = "https://github.com/angrynode/hightorrent_api", branch = "feat-sea-orm", features = [ "sea_orm" ] }
4041
# hightorrent_api = "0.2"
4142
log = "0.4.29"
4243
# SQLite ORM

src/database/category.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use snafu::prelude::*;
66
use std::str::FromStr;
77

88
use crate::database::operator::DatabaseOperator;
9-
use crate::database::{content_folder, operation::*};
9+
use crate::database::{content_folder, operation::*, torrent};
1010
use crate::extractors::normalized_path::*;
1111
use crate::extractors::user::User;
1212
use crate::routes::category::CategoryForm;
@@ -29,6 +29,8 @@ pub struct Model {
2929
pub path: NormalizedPathAbsolute,
3030
#[sea_orm(has_many)]
3131
pub content_folders: HasMany<content_folder::Entity>,
32+
#[sea_orm(has_many)]
33+
pub torrents: HasMany<torrent::Entity>,
3234
}
3335

3436
#[async_trait::async_trait]

src/database/content_folder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::str::FromStr;
99
use crate::database::category::{self, CategoryError};
1010
use crate::database::operation::{Operation, OperationId, OperationLog, OperationType, Table};
1111
use crate::database::operator::DatabaseOperator;
12+
use crate::database::torrent;
1213
use crate::extractors::normalized_path::{NormalizedPathAbsolute, NormalizedPathComponent};
1314
use crate::extractors::user::User;
1415
use crate::routes::content_folder::ContentFolderForm;
@@ -43,6 +44,8 @@ pub struct Model {
4344
pub parent_id: Option<i32>,
4445
#[sea_orm(self_ref, relation_enum = "Parent", from = "parent_id", to = "id")]
4546
pub parent: HasOne<Entity>,
47+
#[sea_orm(has_many)]
48+
pub torrents: HasMany<torrent::Entity>,
4649
}
4750

4851
#[async_trait::async_trait]

src/database/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pub mod category;
33
pub mod content_folder;
44
pub mod operation;
55
pub mod operator;
6+
pub mod torrent;

src/database/operation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
55
use crate::extractors::user::User;
66
use crate::routes::category::CategoryForm;
77
use crate::routes::content_folder::ContentFolderForm;
8+
use crate::routes::torrent::TorrentForm;
89

910
/// Type of operation applied to the database.
1011
#[derive(Clone, Debug, Display, Serialize, Deserialize)]
@@ -24,6 +25,7 @@ pub struct OperationId {
2425
pub enum Table {
2526
Category,
2627
ContentFolder,
28+
Torrent,
2729
}
2830

2931
/// Operation applied to the database.
@@ -34,6 +36,7 @@ pub enum Table {
3436
pub enum Operation {
3537
Category(CategoryForm),
3638
ContentFolder(ContentFolderForm),
39+
Torrent(TorrentForm),
3740
}
3841

3942
impl std::fmt::Display for Operation {

src/database/operator.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::database::{category::CategoryOperator, content_folder::ContentFolderOperator};
1+
use crate::database::{
2+
category::CategoryOperator, content_folder::ContentFolderOperator, torrent::TorrentOperator,
3+
};
24
use crate::extractors::user::User;
35
use crate::state::AppState;
46

@@ -26,4 +28,11 @@ impl DatabaseOperator {
2628
user: self.user.clone(),
2729
}
2830
}
31+
32+
pub fn torrent(&self) -> TorrentOperator {
33+
TorrentOperator {
34+
state: self.state.clone(),
35+
user: self.user.clone(),
36+
}
37+
}
2938
}

0 commit comments

Comments
 (0)