diff --git a/Cargo.lock b/Cargo.lock index c5371e3..a3e3470 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -485,6 +496,18 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fancy-regex" version = "0.10.0" @@ -621,6 +644,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + [[package]] name = "gettext" version = "0.4.0" @@ -661,6 +695,18 @@ name = "hashbrown" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452c155cb93fecdfb02a73dd57b5d8e442c2063bd7aac72f1bc5e4263a43086" +dependencies = [ + "hashbrown", +] [[package]] name = "hermit-abi" @@ -909,6 +955,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "libsqlite3-sys" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8664486da51de68fbb3331d37c2a0fff4b60e988f284670a6a0833a8e6406ad" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "link-cplusplus" version = "1.0.6" @@ -1301,6 +1358,7 @@ dependencies = [ "proc_macros", "regex", "reqwest", + "rusqlite", "tokio", "url", "urlparse", @@ -1448,6 +1506,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "rusqlite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" +dependencies = [ + "bitflags", + "chrono", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1606,6 +1679,12 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + [[package]] name = "socket2" version = "0.4.4" @@ -1926,6 +2005,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "want" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index dfa625c..94e1f4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ parse-size = "1" proc_macros = { path = "proc_macros" } regex = "1" reqwest = { version = "0.11", features = ["brotli", "deflate", "gzip", "rustls-tls", "socks", "stream"] } +rusqlite = { version = "0.28", features = ["bundled", "chrono", "winsqlite3"], optional = true } RustyXML = "0.3" tokio = { version = "1.20", features = ["rt", "macros", "rt-multi-thread", "time"] } url = "2.2" @@ -43,10 +44,12 @@ bindgen = { version = "0.60", optional = true } cmake = { version = "0.1", optional = true } [features] -all = ["exif", "ugoira", "server"] +all = ["db", "db_sqlite", "exif", "ugoira", "server"] avdict = ["bindgen", "cmake", "flagset"] +db = [] +db_sqlite = ["rusqlite"] exif = ["bindgen", "c_fixed_string", "cmake", "link-cplusplus", "utf16string"] -server = ["async-trait", "hyper"] +server = ["async-trait", "db", "hyper"] ugoira = ["avdict", "bindgen", "cmake", "link-cplusplus"] [profile.release-with-debug] diff --git a/doc/db/authors.md b/doc/db/authors.md new file mode 100644 index 0000000..e8404b0 --- /dev/null +++ b/doc/db/authors.md @@ -0,0 +1,10 @@ +| Name | Description | Type | +|:----:|:-----------:|:----:| +| id | User id | integer | +| name | Author name | string | +| creator_id | Fanbox creator id | string | +| icon | File id of icon | integer | +| big_icon | File id of big icon | integer | +| background | File id of background | integer | +| comment | Author comment | string | +| webpage | Author webpage | string | diff --git a/doc/db/files.md b/doc/db/files.md new file mode 100644 index 0000000..9c0eb22 --- /dev/null +++ b/doc/db/files.md @@ -0,0 +1,7 @@ +| Name | Description | Type | +|:----:|:-----------:|:----:| +| id | File id | integer | +| path | The path of the file | string | +| last_modified | The last time the file was modified(HTTP Header) | timestamp | +| etag | The etag(HTTP Header) of the file | string | +| url | The source url | string | diff --git a/doc/db/pixiv_artworks.md b/doc/db/pixiv_artworks.md index ff22f30..decc43b 100644 --- a/doc/db/pixiv_artworks.md +++ b/doc/db/pixiv_artworks.md @@ -5,3 +5,4 @@ | author | Author name | string | | uid | User id of the author | integer | | description | Description of artwork | string | +| count | Number of pages | integer | diff --git a/doc/db/pixiv_files.md b/doc/db/pixiv_files.md new file mode 100644 index 0000000..34d45cf --- /dev/null +++ b/doc/db/pixiv_files.md @@ -0,0 +1,5 @@ +| Name | Description | Type | +|:----:|:-----------:|:----:| +| id | Artwork id | integer | +| file_id | File id | integer | +| page | Page number | integer |