Split up librqbit http_api and tracing_subscriber into separate features (#188)
* fix lints that were under features * Split up some features and fix desktop * fix github script * fix github script * fix github script * try caching check-desktop
This commit is contained in:
parent
33554159bf
commit
37ee8b70ba
12 changed files with 65 additions and 36 deletions
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
|
|
@ -23,6 +23,18 @@ jobs:
|
|||
- run: rustup override set ${{ matrix.rust_version }}
|
||||
- name: cargo check
|
||||
run: cargo check
|
||||
check-desktop:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: rustup toolchain install 1.75
|
||||
run: |
|
||||
rustup toolchain install 1.75
|
||||
- uses: actions/checkout@v4
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup override set 1.75
|
||||
- name: cargo check desktop
|
||||
working-directory: desktop/src-tauri
|
||||
run: cargo check
|
||||
test:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
|
|
|
|||
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -1476,7 +1476,6 @@ dependencies = [
|
|||
"bitvec",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"crypto-hash",
|
||||
"dashmap",
|
||||
"futures",
|
||||
"hex 0.4.3",
|
||||
|
|
@ -1494,7 +1493,6 @@ dependencies = [
|
|||
"lru",
|
||||
"memmap2",
|
||||
"mime_guess",
|
||||
"openssl",
|
||||
"parking_lot",
|
||||
"rand",
|
||||
"regex",
|
||||
|
|
@ -1504,7 +1502,6 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"serde_with",
|
||||
"sha1",
|
||||
"size_format",
|
||||
"sqlx",
|
||||
"tempfile",
|
||||
|
|
@ -2596,9 +2593,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.207"
|
||||
version = "1.0.208"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2"
|
||||
checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
|
@ -2617,9 +2614,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.207"
|
||||
version = "1.0.208"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e"
|
||||
checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ readme = "README.md"
|
|||
|
||||
[features]
|
||||
default = ["default-tls"]
|
||||
http-api = ["axum", "tower-http"]
|
||||
webui = []
|
||||
timed_existence = []
|
||||
default-tls = ["reqwest/default-tls"]
|
||||
rust-tls = ["reqwest/rustls-tls"]
|
||||
storage_middleware = ["lru"]
|
||||
storage_examples = []
|
||||
tracing-subscriber-utils = ["tracing-subscriber"]
|
||||
postgres = ["sqlx"]
|
||||
|
||||
[dependencies]
|
||||
|
|
@ -42,8 +44,8 @@ tokio = { version = "1", features = [
|
|||
"fs",
|
||||
"io-util",
|
||||
] }
|
||||
axum = { version = "0.7.4" }
|
||||
tower-http = { version = "0.5", features = ["cors", "trace"] }
|
||||
axum = { version = "0.7.4", optional = true }
|
||||
tower-http = { version = "0.5", features = ["cors", "trace"], optional = true }
|
||||
tokio-stream = "0.1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
|
@ -64,15 +66,11 @@ parking_lot = "0.12"
|
|||
tracing = "0.1.40"
|
||||
size_format = "1"
|
||||
rand = "0.8"
|
||||
|
||||
openssl = { version = "0.10", optional = true }
|
||||
crypto-hash = { version = "0.3", optional = true }
|
||||
sha1 = { version = "0.10", optional = true }
|
||||
tracing-subscriber = { version = "0.3", default-features = false, features = [
|
||||
"json",
|
||||
"fmt",
|
||||
"env-filter",
|
||||
] }
|
||||
], optional = true }
|
||||
uuid = { version = "1.2", features = ["v4"] }
|
||||
futures = "0.3"
|
||||
url = "2"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use anyhow::{bail, Context};
|
|||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn run_cmd(cwd: &Path, cmd: &str) -> anyhow::Result<()> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let (shell, shell_args) = ("powershell", ["-command"].as_slice());
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@ use std::{collections::HashSet, marker::PhantomData, net::SocketAddr, str::FromS
|
|||
use anyhow::Context;
|
||||
use buffers::ByteBufOwned;
|
||||
use dht::{DhtStats, Id20};
|
||||
use futures::Stream;
|
||||
use http::StatusCode;
|
||||
use librqbit_core::torrent_metainfo::TorrentMetaV1Info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -20,9 +18,15 @@ use crate::{
|
|||
peer::stats::snapshot::{PeerStatsFilter, PeerStatsSnapshot},
|
||||
FileStream, ManagedTorrentHandle,
|
||||
},
|
||||
tracing_subscriber_config_utils::LineBroadcast,
|
||||
};
|
||||
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
use crate::tracing_subscriber_config_utils::LineBroadcast;
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
use futures::Stream;
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream};
|
||||
|
||||
pub use crate::torrent_state::stats::{LiveStats, TorrentStats};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, ApiError>;
|
||||
|
|
@ -33,6 +37,7 @@ pub type Result<T> = std::result::Result<T, ApiError>;
|
|||
pub struct Api {
|
||||
session: Arc<Session>,
|
||||
rust_log_reload_tx: Option<UnboundedSender<String>>,
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
line_broadcast: Option<LineBroadcast>,
|
||||
}
|
||||
|
||||
|
|
@ -127,11 +132,12 @@ impl Api {
|
|||
pub fn new(
|
||||
session: Arc<Session>,
|
||||
rust_log_reload_tx: Option<UnboundedSender<String>>,
|
||||
line_broadcast: Option<LineBroadcast>,
|
||||
#[cfg(feature = "tracing-subscriber-utils")] line_broadcast: Option<LineBroadcast>,
|
||||
) -> Self {
|
||||
Self {
|
||||
session,
|
||||
rust_log_reload_tx,
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
line_broadcast,
|
||||
}
|
||||
}
|
||||
|
|
@ -258,6 +264,7 @@ impl Api {
|
|||
Ok(Default::default())
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
pub fn api_log_lines_stream(
|
||||
&self,
|
||||
) -> Result<
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(feature = "http-api")]
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use http::StatusCode;
|
||||
use serde::{Serialize, Serializer};
|
||||
|
|
@ -147,6 +148,7 @@ impl std::fmt::Display for ApiError {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "http-api")]
|
||||
impl IntoResponse for ApiError {
|
||||
fn into_response(self) -> Response {
|
||||
let mut response = axum::Json(&self).into_response();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Context;
|
||||
use axum::body::Bytes;
|
||||
use axum::extract::{Path, Query, State};
|
||||
use axum::response::{IntoResponse, Redirect};
|
||||
use axum::response::IntoResponse;
|
||||
use axum::routing::{get, post};
|
||||
use futures::future::BoxFuture;
|
||||
use futures::{FutureExt, TryStreamExt};
|
||||
|
|
@ -459,6 +459,8 @@ impl HttpApi {
|
|||
|
||||
#[cfg(feature = "webui")]
|
||||
{
|
||||
use axum::response::Redirect;
|
||||
|
||||
let webui_router = Router::new()
|
||||
.route(
|
||||
"/",
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ mod create_torrent_file;
|
|||
mod dht_utils;
|
||||
pub mod file_info;
|
||||
mod file_ops;
|
||||
#[cfg(feature = "http-api")]
|
||||
pub mod http_api;
|
||||
#[cfg(feature = "http-api")]
|
||||
pub mod http_api_client;
|
||||
mod merge_streams;
|
||||
mod peer_connection;
|
||||
|
|
@ -44,6 +46,7 @@ mod spawn_utils;
|
|||
pub mod storage;
|
||||
mod stream_connect;
|
||||
mod torrent_state;
|
||||
#[cfg(feature = "tracing-subscriber-utils")]
|
||||
pub mod tracing_subscriber_config_utils;
|
||||
mod type_aliases;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ readme = "README.md"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
default = ["default-tls", "webui", "postgres"]
|
||||
default = ["default-tls", "postgres", "webui"]
|
||||
openssl-vendored = ["openssl/vendored"]
|
||||
tokio-console = ["console-subscriber", "tokio/tracing"]
|
||||
webui = ["librqbit/webui"]
|
||||
|
|
@ -23,7 +23,10 @@ debug_slow_disk = ["librqbit/storage_middleware"]
|
|||
postgres = ["librqbit/postgres"]
|
||||
|
||||
[dependencies]
|
||||
librqbit = { path = "../librqbit", default-features = false, version = "7.0.0-beta.0" }
|
||||
librqbit = { path = "../librqbit", default-features = false, features = [
|
||||
"http-api",
|
||||
"tracing-subscriber-utils",
|
||||
], version = "7.0.0-beta.0" }
|
||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||
console-subscriber = { version = "0.2", optional = true }
|
||||
anyhow = "1"
|
||||
|
|
|
|||
10
desktop/src-tauri/Cargo.lock
generated
10
desktop/src-tauri/Cargo.lock
generated
|
|
@ -3031,7 +3031,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rqbit-desktop"
|
||||
version = "7.0.0-beta.0"
|
||||
version = "7.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.21.7",
|
||||
|
|
@ -3213,9 +3213,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.207"
|
||||
version = "1.0.208"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2"
|
||||
checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
|
@ -3234,9 +3234,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.207"
|
||||
version = "1.0.208"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e"
|
||||
checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,11 @@ tauri-build = { version = "1.5", features = [] }
|
|||
tauri = { version = "1.6.7", features = ["shell-open"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
librqbit = { path = "../../crates/librqbit", features = ["webui"] }
|
||||
librqbit = { path = "../../crates/librqbit", features = [
|
||||
"tracing-subscriber-utils",
|
||||
"http-api",
|
||||
"webui",
|
||||
] }
|
||||
tokio = { version = "1.34.0", features = ["rt-multi-thread"] }
|
||||
anyhow = "1.0.75"
|
||||
base64 = "0.21.5"
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use config::RqbitDesktopConfig;
|
|||
use http::StatusCode;
|
||||
use librqbit::{
|
||||
api::{
|
||||
ApiAddTorrentResponse, EmptyJsonResponse, TorrentDetailsResponse, TorrentListResponse,
|
||||
TorrentStats,
|
||||
ApiAddTorrentResponse, EmptyJsonResponse, TorrentDetailsResponse, TorrentIdOrHash,
|
||||
TorrentListResponse, TorrentStats,
|
||||
},
|
||||
dht::PersistentDhtConfig,
|
||||
tracing_subscriber_config_utils::{init_logging, InitLoggingOptions, InitLoggingResult},
|
||||
|
|
@ -261,7 +261,7 @@ async fn torrent_create_from_base64_file(
|
|||
#[tauri::command]
|
||||
async fn torrent_details(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
) -> Result<TorrentDetailsResponse, ApiError> {
|
||||
state.api()?.api_torrent_details(id)
|
||||
}
|
||||
|
|
@ -269,7 +269,7 @@ async fn torrent_details(
|
|||
#[tauri::command]
|
||||
async fn torrent_stats(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
) -> Result<TorrentStats, ApiError> {
|
||||
state.api()?.api_stats_v1(id)
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ async fn torrent_stats(
|
|||
#[tauri::command]
|
||||
async fn torrent_action_delete(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
) -> Result<EmptyJsonResponse, ApiError> {
|
||||
state.api()?.api_torrent_action_delete(id).await
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ async fn torrent_action_delete(
|
|||
#[tauri::command]
|
||||
async fn torrent_action_pause(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
) -> Result<EmptyJsonResponse, ApiError> {
|
||||
state.api()?.api_torrent_action_pause(id).await
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ async fn torrent_action_pause(
|
|||
#[tauri::command]
|
||||
async fn torrent_action_forget(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
) -> Result<EmptyJsonResponse, ApiError> {
|
||||
state.api()?.api_torrent_action_forget(id).await
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ async fn torrent_action_forget(
|
|||
#[tauri::command]
|
||||
async fn torrent_action_start(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
) -> Result<EmptyJsonResponse, ApiError> {
|
||||
state.api()?.api_torrent_action_start(id).await
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ async fn torrent_action_start(
|
|||
#[tauri::command]
|
||||
async fn torrent_action_configure(
|
||||
state: tauri::State<'_, State>,
|
||||
id: usize,
|
||||
id: TorrentIdOrHash,
|
||||
only_files: Vec<usize>,
|
||||
) -> Result<EmptyJsonResponse, ApiError> {
|
||||
state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue