Skip to content

Commit

Permalink
🐛 Add cascade to series metadata (#172)
Browse files Browse the repository at this point in the history
* 🐛 Add cascade to series metadata

I also went ahead and updated a lot of dependencies

* revert tauri upgrade

* upgrade toml

* try tiny tauri bump
  • Loading branch information
aaronleopold authored Oct 6, 2023
1 parent fab2c97 commit f127bb7
Show file tree
Hide file tree
Showing 12 changed files with 504 additions and 288 deletions.
635 changes: 419 additions & 216 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 8 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@ members = [
version = "0.0.0"
rust-version = "1.72.1"

# TODO: replace my fork with next official pcr release when it comes out, I just don't
# have the time for undocumented breaking changes right now
[workspace.dependencies]
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.6.10", features = [
# prisma-client-rust = { git = "https://github.com/stumpapp/prisma-client-rust", rev = "4e9c79c8355dcbb098169ccbc85a9349f8c7882d", features = [
'sqlite-create-many',
"migrations",
"sqlite",
], default-features = false }
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.6.10", features = [
# prisma-client-rust-cli = { git = "https://github.com/stumpapp/prisma-client-rust", rev = "4e9c79c8355dcbb098169ccbc85a9349f8c7882d", features = [
"sqlite-create-many",
"migrations",
"sqlite",
], default-features = false }

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.85"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
tokio = { version = "1.21.2", features = [
# feature for the internal channels (internal communication)
"sync",
Expand All @@ -37,19 +33,15 @@ tokio = { version = "1.21.2", features = [
# needed for detecting shutdown signals (e.g. ctrl+c)
"signal",
] }
async-stream = "0.3.3"
urlencoding = "2.1.2"
async-stream = "0.3.5"
urlencoding = "2.1.3"

### DEV UTILS ###
specta = "1.0.2"
specta = "1.0.5"

### AUTH ###
bcrypt = "0.10.1"
bcrypt = "0.15.0"

### Error Handling + Logging ###
tracing = "0.1.36"
thiserror = "1.0.37"

[patch.crates-io]
# for some reason, async-stream 0.3.4 is getting used instead of 0.3.3 but ONLY IN DOCKER?? So I have to patch it IG?? kms
async-stream = { git = "https://github.com/tokio-rs/async-stream", rev = "e1373e4dede24f7700452e499a46561fb45ea515" }
tracing = "0.1.37"
thiserror = "1.0.49"
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"license": "MIT",
"scripts": {
"tauri": "tauri",
"start": "tauri dev --no-watch",
"vite": "vite --",
"dev": "tauri dev",
"build": "vite build && tauri build",
Expand Down
10 changes: 7 additions & 3 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ edition = "2021"
tauri-build = { version = "1.2.1", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2.4", features = ["api-all", "devtools"] }
# https://github.com/tauri-apps/tauri/issues/5070 -> Once I upgrade Tauri, the workspace inheritance bug will be fixed
# serde_json = { workspace = true }
# serde = { workspace = true }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"

tauri = { version = "1.2.5", features = ["api-all", "devtools"] }

### MISC ###
discord-rich-presence = "0.2.3"
Expand Down
24 changes: 11 additions & 13 deletions apps/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ axum = { version = "0.6.1", features = ["ws", "headers"] }
axum-macros = "0.3.0"
axum-extra = { version = "0.4.2", features = [
"spa",
# "cookie"
"query"
] }
tower-http = { version = "0.3.5", features = [
Expand All @@ -27,21 +26,22 @@ futures-util = "0.3.24"
tokio = { workspace = true }
tokio-util = "0.7.4"
serde = { workspace = true }
# axum-sessions = "0.4.1"
tower = "0.4.13"
tower-sessions = "0.2.1"
async-trait = "0.1.53"
async-stream = { workspace = true }
local-ip-address = { git = "https://github.com/EstebanBorai/local-ip-address.git", tag = "v0.5.1" }
local-ip-address = "0.5.6"
notify = "5.1.0"
urlencoding = { workspace = true }
serde_qs = { version = "0.12.0", features = ["axum"] }
serde-untagged = "0.1"
serde-untagged = "0.1.1"
time = "0.3.29"


### Dev Utils ###
rand = "0.8.5"
utoipa = { version = "3.0.3", features = ["axum_extras"] }
utoipa-swagger-ui = { version = "3.0.2", features = ["axum"] }
utoipa = { version = "3.5.0", features = ["axum_extras"] }
utoipa-swagger-ui = { version = "3.1.5", features = ["axum"] }
specta = { workspace = true }

### Error Handling + Logging ###
Expand All @@ -50,19 +50,17 @@ thiserror = { workspace = true }

### Auth ###
bcrypt = { workspace = true }
base64 = "0.13.0"
time = "0.3.29"
tower = "0.4.13"
base64 = "0.21.4"

### Platform Specific Deps ###
[target.aarch64-unknown-linux-musl.dependencies]
openssl = { version = "0.10.40", features = ["vendored"] }
openssl = { version = "0.10.57", features = ["vendored"] }

[target.armv7-unknown-linux-musleabihf.dependencies]
openssl = { version = "0.10.40", features = ["vendored"] }
openssl = { version = "0.10.57", features = ["vendored"] }

[target.x86_64-unknown-linux-musl.dependencies]
openssl = { version = "0.10.40", features = ["vendored"] }
openssl = { version = "0.10.57", features = ["vendored"] }

[build-dependencies]
chrono = "0.4.19"
chrono = "0.4.31"
10 changes: 7 additions & 3 deletions apps/server/src/middleware/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use axum::{
http::{header, request::Parts, Method, StatusCode},
response::{IntoResponse, Redirect, Response},
};
use base64::{engine::general_purpose::STANDARD, Engine};
use prisma_client_rust::{
prisma_errors::query_engine::{RecordNotFound, UniqueKeyViolation},
QueryError,
Expand Down Expand Up @@ -82,9 +83,12 @@ where
}

let encoded_credentials = auth_header[6..].to_string();
let decoded_bytes = base64::decode(encoded_credentials).map_err(|e| {
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response()
})?;
let decoded_bytes =
STANDARD
.decode(encoded_credentials.as_bytes())
.map_err(|e| {
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response()
})?;
let decoded_credentials =
decode_base64_credentials(decoded_bytes).map_err(|e| {
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response()
Expand Down
21 changes: 8 additions & 13 deletions apps/server/src/routers/api/v1/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,15 @@ async fn tail_log_file() -> Sse<impl Stream<Item = Result<Event, Infallible>>> {
match res {
Ok(event) => {
println!("event: {:?}", event);
match event.kind {
EventKind::Modify(_) => {
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
for line in content.lines().rev() {
println!("line: {}", line);
if !line.is_empty() {
if tx.send(line.to_owned()).is_err() {
break;
}
}
if let EventKind::Modify(_) = event.kind {
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
for line in content.lines().rev() {
println!("line: {}", line);
if !line.is_empty() && tx.send(line.to_owned()).is_err() {
break;
}
},
_ => {},
}
}
},
Err(e) => println!("watch error: {:?}", e),
Expand Down
32 changes: 16 additions & 16 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ serde = { workspace = true }
prisma-client-rust = { workspace = true }
specta = { workspace = true }

rayon = "1.5.3"
futures = "0.3.21"
async-trait = "0.1.53"
rayon = "1.8.0"
futures = "0.3.28"
async-trait = "0.1.73"

### MISC UTILS ###
urlencoding = { workspace = true }
cuid = "1.2.0"
xml-rs = "0.8.4" # used for creating XML docs
serde-xml-rs = "0.5.1" # used for serializing/deserializing xml
serde_json = "1.0.96"
itertools = "0.10.5"
optional_struct = "0.2.0"
utoipa = { version = "3.0.3" }
uuid = "1.4.0"
regex = "1.9.5"
cuid = "1.3.2"
xml-rs = "0.8.19" # used for creating XML docs
serde-xml-rs = "0.6.0" # used for serializing/deserializing xml
serde_json = { workspace = true }
itertools = "0.11.0"
optional_struct = "0.3.1"
utoipa = { version = "3.5.0" }
uuid = "1.4.1"
regex = "1.9.6"
alphanumeric-sort = "1.5.1"

### FILESYSTEM UTILS ###
walkdir = "2.3.2"
walkdir = "2.4.0"
globset = "0.4.9"
dirs = "4.0.0"
trash = "2.0"
infer = "0.7.0"
image = "0.24.2"
webp = "0.2.2"
webp = "0.2.6"
zip = "0.5.13"
epub = "1.2.4"
unrar = { git = "https://github.com/stumpapp/unrar.rs", branch = "feature/typestate" }
# unrar = { version = "0.5.1" }
pdf = "0.8.1"
pdfium-render = "0.8.9"
data-encoding = "2.3.2"
data-encoding = "2.4.0"
ring = "0.16.20"

## ERROR HANDLING + LOGGING ###
thiserror = { workspace = true }
toml = "0.5.9"
toml = "0.8.2"
tracing = { workspace = true }
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
tracing-appender = "0.2.2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_series_metadata" (
"meta_type" TEXT NOT NULL,
"title" TEXT,
"summary" TEXT,
"publisher" TEXT,
"imprint" TEXT,
"comicid" INTEGER,
"volume" INTEGER,
"booktype" TEXT,
"age_rating" INTEGER,
"status" TEXT,
"series_id" TEXT NOT NULL PRIMARY KEY,
CONSTRAINT "series_metadata_series_id_fkey" FOREIGN KEY ("series_id") REFERENCES "series" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_series_metadata" ("age_rating", "booktype", "comicid", "imprint", "meta_type", "publisher", "series_id", "status", "summary", "title", "volume") SELECT "age_rating", "booktype", "comicid", "imprint", "meta_type", "publisher", "series_id", "status", "summary", "title", "volume" FROM "series_metadata";
DROP TABLE "series_metadata";
ALTER TABLE "new_series_metadata" RENAME TO "series_metadata";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
2 changes: 1 addition & 1 deletion core/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ model SeriesMetadata {
/////////////////////////////////////////////
series_id String @id
series Series @relation(fields: [series_id], references: [id])
series Series @relation(fields: [series_id], references: [id], onDelete: Cascade)
@@map("series_metadata")
}
Expand Down
10 changes: 4 additions & 6 deletions core/src/config/stump_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, path::Path};

use optional_struct::OptionalStruct;
use optional_struct::{optional_struct, Applyable};
use serde::{Deserialize, Serialize};
use tracing::debug;

Expand All @@ -11,9 +11,8 @@ use crate::{

// TODO: before I actually use this, test to see if it works well.

#[derive(Serialize, Deserialize, Debug, Clone, OptionalStruct)]
#[optional_name = "PartialStumpConfig"]
#[optional_derive(Deserialize)]
#[optional_struct(PartialStumpConfig)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct StumpConfig {
pub profile: String,
pub port: u16,
Expand Down Expand Up @@ -202,8 +201,7 @@ impl StumpConfig {
impl From<PartialStumpConfig> for StumpConfig {
fn from(partial: PartialStumpConfig) -> StumpConfig {
let mut default = StumpConfig::default();
default.apply_options(partial);

partial.apply_to(&mut default);
default
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"web": "pnpm --filter @stump/web --",
"docs": "pnpm --filter @stump/docs --",
"server": "pnpm --filter @stump/server --",
"dev:desktop": "concurrently -n server,desktop -c green.bold,blue.bold \"pnpm run server dev\" \"pnpm desktop dev\"",
"start:desktop": "concurrently -n server,desktop -c green.bold,blue.bold \"pnpm run server start\" \"pnpm desktop start\"",
"dev:web": "concurrently -n server,web -c green.bold,blue.bold \"pnpm run server dev\" \"pnpm web dev\"",
"core": "pnpm --filter @stump/core --",
"prisma": "pnpm core prisma",
Expand Down

0 comments on commit f127bb7

Please sign in to comment.