Merge pull request 'Update all dependencies' (#7) from renovate/all into main
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #7
This commit is contained in:
Kasper Juul Hermansen 2022-10-28 21:24:13 +00:00
commit acb12c1e33
7 changed files with 163 additions and 95 deletions

View File

@ -8,10 +8,15 @@ steps:
settings:
username: kasperhermansen
password:
from_secret:
docker_secret
from_secret: docker_secret
repo: kasperhermansen/twatch
tags: latest
when:
event:
include:
- push
- tag
- promote
- name: send telegram notification
image: appleboy/drone-telegram
@ -19,4 +24,9 @@ steps:
token:
from_secret: telegram_token
to: 2129601481
format: markdown
format: markdown
depends_on:
- "docker"
when:
status:
- "failure"

176
Cargo.lock generated
View File

@ -70,6 +70,12 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "dotenvy"
version = "0.15.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0"
[[package]]
name = "encoding_rs"
version = "0.8.30"
@ -81,18 +87,18 @@ dependencies = [
[[package]]
name = "enum-iterator"
version = "0.7.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6"
checksum = "2953d1df47ac0eb70086ccabf0275aa8da8591a28bd358ee2b52bd9f9e3ff9e9"
dependencies = [
"enum-iterator-derive",
]
[[package]]
name = "enum-iterator-derive"
version = "0.7.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159"
checksum = "8958699f9359f0b04e691a13850d48b7de329138023876d07cbd024c2c820598"
dependencies = [
"proc-macro2",
"quote",
@ -101,9 +107,9 @@ dependencies = [
[[package]]
name = "env_logger"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272"
dependencies = [
"atty",
"humantime",
@ -344,9 +350,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.16"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
@ -371,34 +377,14 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mio"
version = "0.8.2"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"wasi",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
]
[[package]]
name = "ntapi"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
dependencies = [
"winapi",
"windows-sys 0.42.0",
]
[[package]]
@ -437,7 +423,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
"windows-sys",
"windows-sys 0.34.0",
]
[[package]]
@ -460,18 +446,18 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "proc-macro2"
version = "1.0.36"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [
"unicode-xid",
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.17"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [
"proc-macro2",
]
@ -504,9 +490,9 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "reqwest"
version = "0.11.10"
version = "0.11.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb"
checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"
dependencies = [
"base64",
"bytes",
@ -520,9 +506,9 @@ dependencies = [
"hyper-rustls",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls",
@ -532,6 +518,7 @@ dependencies = [
"serde_urlencoded",
"tokio",
"tokio-rustls",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
@ -569,9 +556,9 @@ dependencies = [
[[package]]
name = "rustls-pemfile"
version = "0.3.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360"
checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55"
dependencies = [
"base64",
]
@ -600,18 +587,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.136"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.136"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
dependencies = [
"proc-macro2",
"quote",
@ -680,13 +667,13 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "syn"
version = "1.0.90"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
"unicode-ident",
]
[[package]]
@ -715,16 +702,16 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.17.0"
version = "1.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee"
checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
@ -809,11 +796,11 @@ dependencies = [
[[package]]
name = "transmission-rpc"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "044b318bbc5d8ebf2830610f4f0da4df2e20a70ff8b8cb53f00c335203211ed5"
checksum = "76798cea8bf001ff34b5bf10cf8b7099905208b73dc5b71befa6f3d8276ecbe2"
dependencies = [
"dotenv",
"dotenvy",
"enum-iterator",
"env_logger",
"log",
@ -853,6 +840,12 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f"
[[package]]
name = "unicode-ident"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "unicode-normalization"
version = "0.1.19"
@ -862,12 +855,6 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "untrusted"
version = "0.7.1"
@ -1034,43 +1021,100 @@ version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_msvc",
"windows_aarch64_msvc 0.34.0",
"windows_i686_gnu 0.34.0",
"windows_i686_msvc 0.34.0",
"windows_x86_64_gnu 0.34.0",
"windows_x86_64_msvc 0.34.0",
]
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.0",
"windows_i686_gnu 0.42.0",
"windows_i686_msvc 0.42.0",
"windows_x86_64_gnu 0.42.0",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
[[package]]
name = "windows_aarch64_msvc"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]
name = "windows_x86_64_msvc"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
[[package]]
name = "winreg"
version = "0.10.1"

View File

@ -1,4 +1,4 @@
FROM rust:slim-bullseye AS builder
FROM harbor.front.kjuulh.io/docker-proxy/library/rust:slim-bullseye AS builder
COPY . /app/builder/
@ -6,11 +6,11 @@ WORKDIR /app/builder/
RUN cargo build --release
FROM debian:bullseye-slim
FROM harbor.front.kjuulh.io/docker-proxy/library/debian:bullseye-slim
COPY --from=builder /app/builder/target/release/ /app/
WORKDIR /app/
ENV RUST_LOG info
CMD ["./twatch"]
CMD ["./twatch"]

View File

@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
twatch_core = {path="../twatch_core"}
tokio = {version="1.17.0", features=["full"]}
env_logger="0.9.0"
log = "0.4.16"
tokio = {version="1.21.2", features=["full"]}
env_logger="0.9.1"
log = "0.4.17"
dotenv = "0.15.0"

View File

@ -1,19 +1,22 @@
use log::info;
use std::env;
use std::env::VarError;
use std::time::Duration;
use log::info;
use twatch_core::App;
use tokio::time::sleep;
use twatch_core::App;
#[tokio::main]
async fn main() -> Result<(), VarError> {
env_logger::init();
dotenv::dotenv();
dotenv::dotenv().expect("to load .env");
let url = env::var("T_URL")?;
let user = env::var("T_USER")?;
let password = env::var("T_PASSWORD")?;
let cycle_seconds = env::var("T_CYCLE").unwrap_or("30".to_string()).parse::<u64>().unwrap_or(30);
let cycle_seconds = env::var("T_CYCLE")
.unwrap_or("30".to_string())
.parse::<u64>()
.unwrap_or(30);
loop {
info!("running clean up cycle");

View File

@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
transmission-rpc = "0.3.6"
env_logger="0.9.0"
log = "0.4.16"
transmission-rpc = "0.3.7"
env_logger="0.9.1"
log = "0.4.17"

View File

@ -1,6 +1,6 @@
use log::info;
use transmission_rpc::types::{BasicAuth, Id, Result, Torrent, Torrents};
use transmission_rpc::TransClient;
use transmission_rpc::types::{Result, BasicAuth, Torrent, Torrents, Id};
use log::{info};
pub struct App {
client: TransClient,
@ -8,29 +8,36 @@ pub struct App {
impl App {
pub fn new(url: &String, username: &String, password: &String) -> Self {
let auth = BasicAuth { user: username.clone(), password: password.clone() };
let auth = BasicAuth {
user: username.clone(),
password: password.clone(),
};
let client = TransClient::with_auth(url.as_str(), auth);
Self {
client
}
Self { client }
}
pub async fn run(&self) -> Result<()> {
pub async fn run(mut self) -> Result<()> {
let response = self.client.torrent_get(None, None).await;
match response {
Ok(res) => self.scan_files(res.arguments).await.unwrap(),
Err(e) => println!("{}", e.to_string())
Err(e) => println!("{}", e.to_string()),
}
return Ok(());
}
async fn scan_files(&self, torrents: Torrents<Torrent>) -> Result<()> {
async fn scan_files(self, torrents: Torrents<Torrent>) -> Result<()> {
let mut torrents_to_remove = Vec::new();
for torrent in torrents.torrents {
match (torrent.id, torrent.is_stalled) {
(Some(id), Some(true)) => {
info!("processing: (id: {}, name: {})", id, torrent.name.unwrap_or("name could not be found from torrent".to_string()));
info!(
"processing: (id: {}, name: {})",
id,
torrent
.name
.unwrap_or("name could not be found from torrent".to_string())
);
torrents_to_remove.push(id);
}
_ => {
@ -49,7 +56,11 @@ impl App {
return Ok(());
}
async fn clean_up_torrents(&self, torrent_ids: Vec<i64>) {
self.client.torrent_remove(torrent_ids.iter().map(|ti| { Id::Id(*ti) }).collect(), true).await;
async fn clean_up_torrents(mut self, torrent_ids: Vec<i64>) {
self.client
.torrent_remove(torrent_ids.iter().map(|ti| Id::Id(*ti)).collect(), true)
.await
.expect("to remove torrent");
}
}
}