mirror of
https://github.com/flibusta-apps/library_updater.git
synced 2025-12-06 15:45:36 +01:00
Compare commits
22 Commits
fa977d7fa7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d99897b0e | |||
| 35dc3cbf6f | |||
| 4625adb6a4 | |||
| 65e23787f1 | |||
| e1af1c2623 | |||
| 788a6d232e | |||
| c8fa902da9 | |||
|
|
d2ba22541c | ||
|
|
9df3aaed03 | ||
| 688246bc23 | |||
| 7fa41a6bf1 | |||
|
|
0cafded7e2 | ||
| f1940e8335 | |||
| 4c2db8d3ec | |||
|
|
24d938bb3a | ||
| ba45905e2a | |||
|
|
9ec2dbbba9 | ||
| f90979c166 | |||
| 3e0d89432f | |||
| fe8652c7d8 | |||
| 69528f371e | |||
|
|
02c2f638a0 |
23
.github/workflows/build_docker_image.yml
vendored
23
.github/workflows/build_docker_image.yml
vendored
@@ -3,18 +3,16 @@ name: Build docker image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- "main"
|
||||
|
||||
jobs:
|
||||
Build-Docker-Image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- id: repository_name
|
||||
@@ -22,16 +20,14 @@ jobs:
|
||||
with:
|
||||
string: ${{ github.repository }}
|
||||
|
||||
-
|
||||
name: Login to ghcr.io
|
||||
- name: Login to ghcr.io
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
-
|
||||
name: Build and push
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v6
|
||||
env:
|
||||
@@ -39,12 +35,11 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
tags: ghcr.io/${{ env.IMAGE }}:latest
|
||||
tags: ghcr.io/${{ env.IMAGE }}:latest,ghcr.io/${{ env.IMAGE }}:${{ github.sha }}
|
||||
context: .
|
||||
file: ./docker/build.dockerfile
|
||||
|
||||
-
|
||||
name: Invoke deployment hook
|
||||
- name: Invoke deployment hook
|
||||
uses: joelwmale/webhook-action@master
|
||||
with:
|
||||
url: ${{ secrets.WEBHOOK_URL }}
|
||||
url: ${{ secrets.WEBHOOK_URL }}?LIBRARY_UPDATER_TAG=${{ github.sha }}
|
||||
|
||||
55
.github/workflows/rust-clippy.yml
vendored
Normal file
55
.github/workflows/rust-clippy.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
# rust-clippy is a tool that runs a bunch of lints to catch common
|
||||
# mistakes in your Rust code and help improve your Rust code.
|
||||
# More details at https://github.com/rust-lang/rust-clippy
|
||||
# and https://rust-lang.github.io/rust-clippy/
|
||||
|
||||
name: rust-clippy analyze
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '38 0 * * 4'
|
||||
|
||||
jobs:
|
||||
rust-clippy-analyze:
|
||||
name: Run rust-clippy analyzing
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
components: clippy
|
||||
override: true
|
||||
|
||||
- name: Install required cargo
|
||||
run: cargo install clippy-sarif sarif-fmt
|
||||
|
||||
- name: Run rust-clippy
|
||||
run:
|
||||
cargo clippy
|
||||
--all-features
|
||||
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload analysis results to GitHub
|
||||
uses: github/codeql-action/upload-sarif@v4
|
||||
with:
|
||||
sarif_file: rust-clippy-results.sarif
|
||||
wait-for-processing: true
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/target
|
||||
.vscode
|
||||
/.vscode
|
||||
/bruno
|
||||
|
||||
1481
Cargo.lock
generated
1481
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
27
Cargo.toml
27
Cargo.toml
@@ -3,11 +3,24 @@ name = "library_updater"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
debug = false
|
||||
strip = true
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
panic = 'abort'
|
||||
|
||||
[profile.profiling]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
strip = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
sql-parse = "0.24.0"
|
||||
tokio = { version = "1.44.1", features = ["full"] }
|
||||
sql-parse = "0.26.0"
|
||||
tokio = { version = "1.44.2", features = ["full"] }
|
||||
tokio-postgres = { version = "0.7.13", features = ["with-chrono-0_4"] }
|
||||
deadpool-postgres = "0.14.1"
|
||||
async-trait = "0.1.88"
|
||||
@@ -16,18 +29,18 @@ futures = "0.3.31"
|
||||
reqwest = { version = "0.12.15", features = ["stream"] }
|
||||
tokio-util = { version = "0.7.14", features = ["compat"] }
|
||||
async-compression = { version = "0.4.21", features = ["futures-io", "gzip"] }
|
||||
sentry = { version = "0.36.0", features = ["debug-images"] }
|
||||
sentry = { version = "0.42.0", features = ["debug-images"] }
|
||||
lazy_static = "1.5.0"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_json = "1.0.140"
|
||||
tokio-cron-scheduler = "0.13.0"
|
||||
tokio-cron-scheduler = "0.14.0"
|
||||
axum = "0.8.1"
|
||||
ammonia = "4.0.0"
|
||||
ammonia = "4.1.2"
|
||||
maplit = "1.0.2"
|
||||
|
||||
tracing = "0.1.41"
|
||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"]}
|
||||
sentry-tracing = "0.36.0"
|
||||
sentry-tracing = "0.42.0"
|
||||
|
||||
tower-http = { version = "0.6.2", features = ["trace"] }
|
||||
dotenvy = "0.15.0"
|
||||
|
||||
34
src/types.rs
34
src/types.rs
@@ -828,28 +828,26 @@ impl FromVecExpression<Genre> for Genre {
|
||||
#[async_trait]
|
||||
impl Update for Genre {
|
||||
async fn before_update(client: &Client) -> Result<(), Box<tokio_postgres::Error>> {
|
||||
match client.execute(
|
||||
match client
|
||||
.execute(
|
||||
"
|
||||
CREATE OR REPLACE FUNCTION update_book_sequence(source_ smallint, book_ integer, genre_ integer) RETURNS void AS $$
|
||||
DECLARE
|
||||
book_id integer := -1;
|
||||
genre_id integer := -1;
|
||||
CREATE OR REPLACE FUNCTION update_genre(
|
||||
source_ smallint, remote_id_ int, code_ varchar, description_ varchar, meta_ varchar
|
||||
) RETURNS void AS $$
|
||||
BEGIN
|
||||
SELECT id INTO book_id FROM books WHERE source = source_ AND remote_id = book_;
|
||||
|
||||
IF book_id IS NULL THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
SELECT id INTO genre_id FROM genres WHERE source = source_ AND remote_id = genre_;
|
||||
IF EXISTS (SELECT * FROM book_genres WHERE book = book_id AND genre = genre_id) THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
INSERT INTO book_genres (book, genre) VALUES (book_id, genre_id);
|
||||
INSERT INTO genres (source, remote_id, code, description, meta)
|
||||
VALUES (source_, remote_id_, code_, description_, meta_)
|
||||
ON CONFLICT (source, remote_id) DO UPDATE SET
|
||||
code = EXCLUDED.code,
|
||||
description = EXCLUDED.description,
|
||||
meta = EXCLUDED.meta;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
"
|
||||
, &[]).await {
|
||||
",
|
||||
&[],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(Box::new(err)),
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ async fn download_file(filename_str: &str) -> Result<(), Box<dyn std::error::Err
|
||||
|
||||
let data = response
|
||||
.bytes_stream()
|
||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
|
||||
.map_err(std::io::Error::other)
|
||||
.into_async_read();
|
||||
|
||||
let decoder = GzipDecoder::new(data);
|
||||
|
||||
Reference in New Issue
Block a user