Compare commits

...

23 Commits

Author SHA1 Message Date
dependabot[bot]
ae74dc94bb Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-21 00:06:11 +00:00
7d99897b0e Use ON CONFLICT upsert for genres
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
Replace the previous IF EXISTS/UPDATE/INSERT logic in the update_genre
PL/pgSQL function with a single INSERT ... ON CONFLICT DO UPDATE to
perform an atomic upsert and avoid races. Reformat the client.execute
call for readability.
2025-10-25 21:37:52 +02:00
35dc3cbf6f Remove DROP FUNCTION IF EXISTS from Genre update 2025-10-25 21:33:29 +02:00
4625adb6a4 Update .gitignore and drop update_genre first 2025-10-25 21:01:11 +02:00
65e23787f1 Add update_genre function to upsert genres
Replace previous function that managed book_genres. New SQL function
upserts the genres table by source and remote_id, updating code,
description and meta or inserting a new row. Removed book lookup and
book_genres insertion.
2025-10-25 20:49:36 +02:00
e1af1c2623 Simplify error mapping in download_file
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
2025-10-14 18:06:56 +02:00
788a6d232e Merge pull request #38 from flibusta-apps/dependabot/github_actions/github/codeql-action-4
Bump github/codeql-action from 3 to 4
2025-10-14 18:05:47 +02:00
c8fa902da9 Merge pull request #37 from flibusta-apps/dependabot/cargo/ammonia-4.1.2
Bump ammonia from 4.1.1 to 4.1.2
2025-10-14 18:05:17 +02:00
dependabot[bot]
d2ba22541c Bump github/codeql-action from 3 to 4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-08 00:06:02 +00:00
dependabot[bot]
9df3aaed03 Bump ammonia from 4.1.1 to 4.1.2
Bumps [ammonia](https://github.com/rust-ammonia/ammonia) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/rust-ammonia/ammonia/releases)
- [Changelog](https://github.com/rust-ammonia/ammonia/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-ammonia/ammonia/compare/v4.1.1...v4.1.2)

---
updated-dependencies:
- dependency-name: ammonia
  dependency-version: 4.1.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-22 15:50:03 +00:00
688246bc23 Merge pull request #35 from flibusta-apps/dependabot/github_actions/actions/checkout-5
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
Bump actions/checkout from 4 to 5
2025-09-10 17:04:27 +02:00
7fa41a6bf1 Update deps
Some checks failed
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
Build docker image / Build-Docker-Image (push) Has been cancelled
2025-08-31 13:55:43 +02:00
dependabot[bot]
0cafded7e2 Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-18 00:22:11 +00:00
f1940e8335 Create rust-clippy.yml
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
2025-08-17 23:36:46 +02:00
4c2db8d3ec Merge pull request #34 from flibusta-apps/dependabot/cargo/slab-0.4.11
Bump slab from 0.4.10 to 0.4.11
2025-08-17 23:18:11 +02:00
dependabot[bot]
24d938bb3a Bump slab from 0.4.10 to 0.4.11
Bumps [slab](https://github.com/tokio-rs/slab) from 0.4.10 to 0.4.11.
- [Release notes](https://github.com/tokio-rs/slab/releases)
- [Changelog](https://github.com/tokio-rs/slab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/slab/compare/v0.4.10...v0.4.11)

---
updated-dependencies:
- dependency-name: slab
  dependency-version: 0.4.11
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-17 21:14:32 +00:00
ba45905e2a Merge pull request #33 from flibusta-apps/dependabot/github_actions/actions/checkout-5
Bump actions/checkout from 4 to 5
2025-08-17 23:13:39 +02:00
dependabot[bot]
9ec2dbbba9 Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 08:51:26 +00:00
f90979c166 Optimize release build
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
2025-06-28 22:36:22 +02:00
3e0d89432f Update deps
Some checks are pending
Build docker image / Build-Docker-Image (push) Waiting to run
2025-06-28 22:16:06 +02:00
fe8652c7d8 Update dependencies and improve Docker image build workflow
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
- Update Rust dependencies in Cargo.lock to latest versions - Tag Docker
images with both `latest` and commit SHA - Pass commit SHA as a query
parameter to deployment webhook - Refactor GitHub Actions workflow for
cleaner YAML structure
2025-06-21 22:41:15 +02:00
69528f371e Merge pull request #32 from flibusta-apps/dependabot/cargo/tokio-1.44.2
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
Bump tokio from 1.44.1 to 1.44.2
2025-04-08 15:56:22 +02:00
dependabot[bot]
02c2f638a0 Bump tokio from 1.44.1 to 1.44.2
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.44.1 to 1.44.2.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.44.1...tokio-1.44.2)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.44.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-08 02:11:21 +00:00
7 changed files with 1048 additions and 583 deletions

View File

@@ -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@v6
-
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
View 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@v6
- 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
View File

@@ -1,2 +1,3 @@
/target
.vscode
/.vscode
/bruno

1481
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -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"

View File

@@ -828,30 +828,28 @@ 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(
"
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;
match client
.execute(
"
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 {
Ok(_) => Ok(()),
Err(err) => Err(Box::new(err)),
",
&[],
)
.await
{
Ok(_) => Ok(()),
Err(err) => Err(Box::new(err)),
}
}

View File

@@ -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);