Skip to content

Commit d0271d8

Browse files
committed
refactor: use lib as project
1 parent e2aec33 commit d0271d8

File tree

9 files changed

+896
-882
lines changed

9 files changed

+896
-882
lines changed

Cargo.lock

Lines changed: 861 additions & 691 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
[workspace]
2-
members = [
3-
"check-pr",
4-
"check-cmt"
5-
]
6-
resolver = "2"
7-
8-
[workspace.package]
1+
[package]
2+
name = "byrdocs-check"
93
version = "0.1.0"
10-
edition = "2021"
11-
description = "A github action script to check metadata for byrdocs"
12-
license = " MIT"
4+
edition = "2024"
5+
6+
[dependencies]
7+
anyhow = "1.0.89"
8+
encoding_rs = "0.8.35"
9+
image = "0.25.2"
10+
isbn = "0.4.0"
11+
md5 = "0.7.0"
12+
pdfium-render = "0.8.25"
13+
regex = "1.11.0"
14+
reqwest = { version = "0.12.8", features = ["json"] }
15+
rusoto = "0.24.2"
16+
rusoto_core = "0.48.0"
17+
rusoto_s3 = "0.48.0"
18+
serde = { version = "1.0.210", features = ["derive"] }
19+
serde_json = "1.0.128"
20+
serde_yaml = "0.9.34"
21+
tokio = { version = "1.40.0", features = ["full"] }
22+
webp = "0.3.0"
23+
zip = "2.2.2"

check-cmt/Cargo.toml

Lines changed: 0 additions & 25 deletions
This file was deleted.

check-pr/Cargo.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

check-pr/src/metadata.rs

Lines changed: 0 additions & 121 deletions
This file was deleted.

check-pr/src/main.rs renamed to src/bin/check-format.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
mod metadata;
2-
31
use rusoto_core::HttpClient;
42
use rusoto_s3::S3;
53
use std::path::Path;
@@ -8,7 +6,7 @@ use tokio::{
86
io::{AsyncReadExt, BufReader},
97
};
108

11-
use crate::metadata::*;
9+
use byrdocs_check::metadata::*;
1210

1311
struct Input {
1412
dir: String,
@@ -95,9 +93,11 @@ async fn main() -> anyhow::Result<()> {
9593
.get(format!("{}/api/file/notPublished", input.backend_url))
9694
.bearer_auth(input.backend_token)
9795
.send()
98-
.await?
96+
.await
97+
.unwrap()
9998
.json::<ApiResult>()
100-
.await?;
99+
.await
100+
.unwrap();
101101

102102
let mut success_book = 0;
103103
let mut success_test = 0;

check-cmt/src/main.rs renamed to src/bin/upload-metadata.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
mod metadata;
2-
31
use pdfium_render::prelude::{PdfRenderConfig, Pdfium};
42
use rusoto_core::HttpClient;
5-
use rusoto_s3::{Object, S3Client, S3};
3+
use rusoto_s3::{Object, S3, S3Client};
64
use serde::Serialize;
75
use serde_json::{json, to_string_pretty};
86
use std::{collections::HashSet, path::Path};
@@ -14,7 +12,7 @@ use tokio::{
1412
use webp::Encoder;
1513
use zip::{HasZipMetadata, ZipArchive};
1614

17-
use metadata::*;
15+
use byrdocs_check::metadata::*;
1816

1917
#[derive(serde::Deserialize, Debug)]
2018
#[allow(dead_code)]

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod metadata;

check-cmt/src/metadata.rs renamed to src/metadata.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use serde::{ser::SerializeStruct, Deserialize, Serialize};
1+
use serde::{Deserialize, Serialize, ser::SerializeStruct};
22

3-
#[derive(serde::Deserialize, Debug, Serialize, Clone, Copy)]
3+
#[derive(serde::Deserialize, Debug, Serialize, Clone)]
44
#[serde(deny_unknown_fields)]
55
pub enum Type {
66
#[serde(rename = "test")]
@@ -39,6 +39,7 @@ pub struct Test {
3939
pub time: Time,
4040
pub filetype: String,
4141
pub content: Vec<String>,
42+
#[serde(skip_deserializing)]
4243
pub filesize: Option<i64>,
4344
}
4445

@@ -48,9 +49,7 @@ pub struct Test {
4849
pub struct Time {
4950
pub start: String,
5051
pub end: String,
51-
#[serde(skip_serializing_if = "is_none_or_empty_string")]
5252
pub semester: Option<String>,
53-
#[serde(skip_serializing_if = "is_none_or_empty_string")]
5453
pub stage: Option<String>,
5554
}
5655

@@ -79,6 +78,7 @@ pub struct Book {
7978
pub publisher: Option<String>,
8079
pub isbn: Vec<String>,
8180
pub filetype: String,
81+
#[serde(skip_deserializing)]
8282
pub filesize: Option<i64>,
8383
}
8484

@@ -90,6 +90,7 @@ pub struct Doc {
9090
pub filetype: String,
9191
pub course: Vec<Course>,
9292
pub content: Vec<String>,
93+
#[serde(skip_deserializing)]
9394
pub filesize: Option<i64>,
9495
}
9596

0 commit comments

Comments
 (0)