Compare commits
No commits in common. "e9e708b833377986cf4f98863056ca087f6f5ddf" and "a604e4472ddd8bd15295003ac100a205490f5d99" have entirely different histories.
e9e708b833
...
a604e4472d
16 changed files with 575 additions and 1203 deletions
|
@ -10,5 +10,5 @@ max_line_length = 88
|
||||||
[{Makefile,*.go}]
|
[{Makefile,*.go}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
|
|
||||||
[*.{json,md,rst,ini,yml,yaml,xml,html,js,jsx,ts,tsx,vue,svelte,hbs}]
|
[*.{json,md,rst,ini,yml,yaml,xml,html,js,jsx,ts,tsx,vue,svelte}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
167
Cargo.lock
generated
167
Cargo.lock
generated
|
@ -150,11 +150,9 @@ dependencies = [
|
||||||
"envy",
|
"envy",
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"governor",
|
|
||||||
"headers",
|
"headers",
|
||||||
"hex",
|
"hex",
|
||||||
"http",
|
"http",
|
||||||
"humansize",
|
|
||||||
"mime",
|
"mime",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -171,6 +169,7 @@ dependencies = [
|
||||||
"serde-env",
|
"serde-env",
|
||||||
"serde-hex",
|
"serde-hex",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"siphasher",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
|
@ -532,19 +531,6 @@ dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dashmap"
|
|
||||||
version = "5.5.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"hashbrown",
|
|
||||||
"lock_api",
|
|
||||||
"once_cell",
|
|
||||||
"parking_lot_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deflate64"
|
name = "deflate64"
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
|
@ -697,21 +683,6 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures"
|
|
||||||
version = "0.3.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
|
|
||||||
dependencies = [
|
|
||||||
"futures-channel",
|
|
||||||
"futures-core",
|
|
||||||
"futures-executor",
|
|
||||||
"futures-io",
|
|
||||||
"futures-sink",
|
|
||||||
"futures-task",
|
|
||||||
"futures-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-channel"
|
name = "futures-channel"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
|
@ -719,7 +690,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -728,17 +698,6 @@ version = "0.3.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-executor"
|
|
||||||
version = "0.3.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core",
|
|
||||||
"futures-task",
|
|
||||||
"futures-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-io"
|
name = "futures-io"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
|
@ -758,17 +717,6 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-macro"
|
|
||||||
version = "0.3.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.66",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-sink"
|
name = "futures-sink"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
|
@ -781,28 +729,16 @@ version = "0.3.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
|
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-timer"
|
|
||||||
version = "3.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-util"
|
name = "futures-util"
|
||||||
version = "0.3.30"
|
version = "0.3.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-channel",
|
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
|
||||||
"futures-macro",
|
|
||||||
"futures-sink",
|
|
||||||
"futures-task",
|
"futures-task",
|
||||||
"memchr",
|
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
"slab",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -838,26 +774,6 @@ version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "governor"
|
|
||||||
version = "0.6.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "68a7f542ee6b35af73b06abc0dad1c1bae89964e4e253bc4b587b91c9637867b"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"dashmap",
|
|
||||||
"futures",
|
|
||||||
"futures-timer",
|
|
||||||
"no-std-compat",
|
|
||||||
"nonzero_ext",
|
|
||||||
"parking_lot",
|
|
||||||
"portable-atomic",
|
|
||||||
"quanta",
|
|
||||||
"rand",
|
|
||||||
"smallvec 1.13.2",
|
|
||||||
"spinning_top",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "h2"
|
name = "h2"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
|
@ -974,15 +890,6 @@ version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "humansize"
|
|
||||||
version = "2.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
|
|
||||||
dependencies = [
|
|
||||||
"libm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humantime"
|
name = "humantime"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -1257,24 +1164,12 @@ dependencies = [
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "no-std-compat"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nodrop"
|
name = "nodrop"
|
||||||
version = "0.1.14"
|
version = "0.1.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nonzero_ext"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
|
@ -1478,12 +1373,6 @@ version = "0.3.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "portable-atomic"
|
|
||||||
version = "1.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powerfmt"
|
name = "powerfmt"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -1535,21 +1424,6 @@ dependencies = [
|
||||||
"unarray",
|
"unarray",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quanta"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-utils",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"raw-cpuid",
|
|
||||||
"wasi",
|
|
||||||
"web-sys",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-error"
|
name = "quick-error"
|
||||||
version = "1.2.3"
|
version = "1.2.3"
|
||||||
|
@ -1616,15 +1490,6 @@ dependencies = [
|
||||||
"rand_core",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "raw-cpuid"
|
|
||||||
version = "11.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.5.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
@ -1703,12 +1568,10 @@ dependencies = [
|
||||||
"system-configuration",
|
"system-configuration",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-native-tls",
|
"tokio-native-tls",
|
||||||
"tokio-util",
|
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"wasm-streams",
|
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
|
@ -1967,6 +1830,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "siphasher"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.9"
|
version = "0.4.9"
|
||||||
|
@ -2001,15 +1870,6 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spinning_top"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300"
|
|
||||||
dependencies = [
|
|
||||||
"lock_api",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
@ -2514,19 +2374,6 @@ version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-streams"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129"
|
|
||||||
dependencies = [
|
|
||||||
"futures-util",
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.69"
|
version = "0.3.69"
|
||||||
|
|
|
@ -11,11 +11,9 @@ dotenvy = "0.15.7"
|
||||||
envy = { path = "crates/envy" }
|
envy = { path = "crates/envy" }
|
||||||
flate2 = "1.0.30"
|
flate2 = "1.0.30"
|
||||||
futures-lite = "2.3.0"
|
futures-lite = "2.3.0"
|
||||||
governor = "0.6.3"
|
|
||||||
headers = "0.4.0"
|
headers = "0.4.0"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
http = "1.1.0"
|
http = "1.1.0"
|
||||||
humansize = "2.1.3"
|
|
||||||
mime = "0.3.17"
|
mime = "0.3.17"
|
||||||
mime_guess = "2.0.4"
|
mime_guess = "2.0.4"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
|
@ -25,11 +23,12 @@ pin-project = "1.1.5"
|
||||||
quick_cache = "0.5.1"
|
quick_cache = "0.5.1"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
regex = "1.10.4"
|
regex = "1.10.4"
|
||||||
reqwest = { version = "0.12.4", features = ["json", "stream"] }
|
reqwest = { version = "0.12.4", features = ["json"] }
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
serde-env = "0.1.1"
|
serde-env = "0.1.1"
|
||||||
serde-hex = "0.1.0"
|
serde-hex = "0.1.0"
|
||||||
serde_json = "1.0.117"
|
serde_json = "1.0.117"
|
||||||
|
siphasher = "1.0.1"
|
||||||
thiserror = "1.0.61"
|
thiserror = "1.0.61"
|
||||||
tokio = { version = "1.37.0", features = ["macros", "fs", "rt-multi-thread"] }
|
tokio = { version = "1.37.0", features = ["macros", "fs", "rt-multi-thread"] }
|
||||||
tokio-util = { version = "0.7.11", features = ["io"] }
|
tokio-util = { version = "0.7.11", features = ["io"] }
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 13.229 13.229"><g aria-label="AV" style="stroke-width:.264583"><path d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z" style="fill:#888;fill-opacity:1"/><path d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z" style="fill:#ddd;fill-opacity:1;stroke-width:.264583"/></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 13.229 13.229"><g aria-label="AV" style="font-size:10.5833px;line-height:1.25;stroke-width:.264583"><path d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z" style="fill:#888;fill-opacity:1"/><path d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z" style="font-size:10.5833px;line-height:1.25;fill:#ddd;fill-opacity:1;stroke-width:.264583"/></g></svg>
|
||||||
|
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 619 B |
115
src/app.rs
115
src/app.rs
|
@ -1,4 +1,4 @@
|
||||||
use std::{net::SocketAddr, ops::Bound, path::PathBuf, sync::Arc};
|
use std::{ops::Bound, path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use async_zip::tokio::read::ZipEntryReader;
|
use async_zip::tokio::read::ZipEntryReader;
|
||||||
use axum::{
|
use axum::{
|
||||||
|
@ -23,13 +23,13 @@ use tokio_util::{
|
||||||
use tower_http::trace::{DefaultOnResponse, TraceLayer};
|
use tower_http::trace::{DefaultOnResponse, TraceLayer};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
artifact_api::{Artifact, ArtifactApi},
|
artifact_api::{Artifact, ArtifactApi, ArtifactOrRun},
|
||||||
cache::{Cache, CacheEntry, GetFileResult, GetFileResultFile, IndexEntry},
|
cache::{Cache, CacheEntry, GetEntryResult, GetFileResult, GetFileResultFile, IndexEntry},
|
||||||
config::Config,
|
config::Config,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
gzip_reader::{PrecompressedGzipReader, GZIP_EXTRA_LEN},
|
gzip_reader::{PrecompressedGzipReader, GZIP_EXTRA_LEN},
|
||||||
query::Query,
|
query::Query,
|
||||||
templates::{self, ArtifactItem, LinkItem},
|
templates::{self, LinkItem},
|
||||||
util::{self, InsertTypedHeader},
|
util::{self, InsertTypedHeader},
|
||||||
App,
|
App,
|
||||||
};
|
};
|
||||||
|
@ -70,13 +70,11 @@ impl App {
|
||||||
let listener = tokio::net::TcpListener::bind(address).await?;
|
let listener = tokio::net::TcpListener::bind(address).await?;
|
||||||
tracing::info!("Listening on http://{address}");
|
tracing::info!("Listening on http://{address}");
|
||||||
|
|
||||||
let state = self.new_state();
|
|
||||||
let real_ip_header = state.i.cfg.load().real_ip_header.clone();
|
|
||||||
let router = Router::new()
|
let router = Router::new()
|
||||||
// Prevent search indexing since artifactview serves temporary artifacts
|
// Prevent search indexing since artifactview serves temporary artifacts
|
||||||
.route(
|
.route(
|
||||||
"/robots.txt",
|
"/robots.txt",
|
||||||
get(|| async { "# PLEASE dont scrape this website.\n# All of the data here is fetched from the public GitHub/Gitea APIs, this app is open source and it is not running on some Fortune 500 company server. \n\nUser-agent: *\nDisallow: /\n" }),
|
get(|| async { "User-agent: *\nDisallow: /\n" }),
|
||||||
)
|
)
|
||||||
// Put the API in the .well-known folder, since it is disabled for pages
|
// Put the API in the .well-known folder, since it is disabled for pages
|
||||||
.route("/.well-known/api/artifacts", get(Self::get_artifacts))
|
.route("/.well-known/api/artifacts", get(Self::get_artifacts))
|
||||||
|
@ -89,21 +87,16 @@ impl App {
|
||||||
.route("/", get(Self::get_page))
|
.route("/", get(Self::get_page))
|
||||||
.route("/", post(Self::post_homepage))
|
.route("/", post(Self::post_homepage))
|
||||||
.fallback(get(Self::get_page))
|
.fallback(get(Self::get_page))
|
||||||
.with_state(state)
|
.with_state(self.new_state())
|
||||||
// Log requests
|
// Log requests
|
||||||
.layer(
|
.layer(
|
||||||
TraceLayer::new_for_http()
|
TraceLayer::new_for_http()
|
||||||
.make_span_with(move |request: &Request<Body>| {
|
.make_span_with(|request: &Request<Body>| {
|
||||||
let ip = util::get_ip_address(request, real_ip_header.as_deref()).map(|ip| ip.to_string()).unwrap_or_default();
|
tracing::error_span!("request", url = util::full_url_from_request(request),)
|
||||||
tracing::error_span!("request", url = util::full_url_from_request(request), ip)
|
|
||||||
})
|
})
|
||||||
.on_response(DefaultOnResponse::new().level(tracing::Level::INFO)),
|
.on_response(DefaultOnResponse::new().level(tracing::Level::INFO)),
|
||||||
);
|
);
|
||||||
axum::serve(
|
axum::serve(listener, router).await?;
|
||||||
listener,
|
|
||||||
router.into_make_service_with_connect_info::<SocketAddr>(),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,26 +120,22 @@ impl App {
|
||||||
let query = Query::from_subdomain(subdomain)?;
|
let query = Query::from_subdomain(subdomain)?;
|
||||||
let path = percent_encoding::percent_decode_str(uri.path()).decode_utf8_lossy();
|
let path = percent_encoding::percent_decode_str(uri.path()).decode_utf8_lossy();
|
||||||
let hdrs = request.headers();
|
let hdrs = request.headers();
|
||||||
let ip = util::get_ip_address(&request, state.i.cfg.load().real_ip_header.as_deref())?;
|
|
||||||
|
|
||||||
match query {
|
|
||||||
Query::Artifact(query) => {
|
|
||||||
let entry_res = state.i.cache.get_entry(&state.i.api, &query, &ip).await?;
|
|
||||||
let entry = entry_res.entry;
|
|
||||||
if entry_res.downloaded {
|
|
||||||
state.garbage_collect();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let res = state.i.cache.get_entry(&state.i.api, &query).await?;
|
||||||
|
match res {
|
||||||
|
GetEntryResult::Entry { entry, zip_path } => {
|
||||||
match entry.get_file(&path, uri.query().unwrap_or_default())? {
|
match entry.get_file(&path, uri.query().unwrap_or_default())? {
|
||||||
GetFileResult::File(res) => {
|
GetFileResult::File(res) => {
|
||||||
Self::serve_artifact_file(state, entry, entry_res.zip_path, res, hdrs)
|
Self::serve_artifact_file(state, entry, zip_path, res, hdrs).await
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
GetFileResult::Listing(listing) => {
|
GetFileResult::Listing(listing) => {
|
||||||
if !path.ends_with('/') {
|
if !path.ends_with('/') {
|
||||||
return Ok(Redirect::to(&format!("{path}/")).into_response());
|
return Ok(Redirect::to(&format!("{path}/")).into_response());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: store actual artifact names
|
||||||
|
let artifact_name = format!("A{}", query.artifact.unwrap());
|
||||||
|
|
||||||
let mut path_components = vec![
|
let mut path_components = vec![
|
||||||
LinkItem {
|
LinkItem {
|
||||||
name: query.shortid(),
|
name: query.shortid(),
|
||||||
|
@ -156,7 +145,7 @@ impl App {
|
||||||
.url_with_subdomain(&query.subdomain_with_artifact(None)),
|
.url_with_subdomain(&query.subdomain_with_artifact(None)),
|
||||||
},
|
},
|
||||||
LinkItem {
|
LinkItem {
|
||||||
name: entry.name.to_owned(),
|
name: artifact_name.to_owned(),
|
||||||
url: "/".to_string(),
|
url: "/".to_string(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -173,8 +162,7 @@ impl App {
|
||||||
let tmpl = templates::Listing {
|
let tmpl = templates::Listing {
|
||||||
main_url: state.i.cfg.main_url(),
|
main_url: state.i.cfg.main_url(),
|
||||||
version: templates::Version,
|
version: templates::Version,
|
||||||
run_url: &query.forge_url(),
|
artifact_name: &artifact_name,
|
||||||
artifact_name: &entry.name,
|
|
||||||
path_components,
|
path_components,
|
||||||
n_dirs: listing.n_dirs,
|
n_dirs: listing.n_dirs,
|
||||||
n_files: listing.n_files,
|
n_files: listing.n_files,
|
||||||
|
@ -188,9 +176,7 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Query::Run(query) => {
|
GetEntryResult::Artifacts(artifacts) => {
|
||||||
let artifacts = state.i.api.list(&query).await?;
|
|
||||||
|
|
||||||
if uri.path() != "/" {
|
if uri.path() != "/" {
|
||||||
return Err(Error::NotFound("path".into()));
|
return Err(Error::NotFound("path".into()));
|
||||||
}
|
}
|
||||||
|
@ -199,16 +185,11 @@ impl App {
|
||||||
}
|
}
|
||||||
let tmpl = templates::Selection {
|
let tmpl = templates::Selection {
|
||||||
main_url: state.i.cfg.main_url(),
|
main_url: state.i.cfg.main_url(),
|
||||||
version: templates::Version,
|
|
||||||
run_url: &query.forge_url(),
|
run_url: &query.forge_url(),
|
||||||
run_name: &query.shortid(),
|
run_name: &query.shortid(),
|
||||||
publisher: LinkItem {
|
|
||||||
name: query.user.to_owned(),
|
|
||||||
url: format!("https://{}/{}", query.host, query.user),
|
|
||||||
},
|
|
||||||
artifacts: artifacts
|
artifacts: artifacts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|a| ArtifactItem::from_artifact(a, &query, &state.i.cfg))
|
.map(|a| LinkItem::from_artifact(a, &query, &state.i.cfg))
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
Ok(Response::builder()
|
Ok(Response::builder()
|
||||||
|
@ -252,7 +233,7 @@ impl App {
|
||||||
|
|
||||||
// Dont serve files above the configured size limit
|
// Dont serve files above the configured size limit
|
||||||
let lim = state.i.cfg.load().max_file_size;
|
let lim = state.i.cfg.load().max_file_size;
|
||||||
if lim.is_some_and(|lim| file.uncompressed_size > lim.into()) {
|
if lim.is_some_and(|lim| file.uncompressed_size > lim) {
|
||||||
return Err(Error::BadRequest(
|
return Err(Error::BadRequest(
|
||||||
format!(
|
format!(
|
||||||
"file too large (size: {}, limit: {})",
|
"file too large (size: {}, limit: {})",
|
||||||
|
@ -265,25 +246,29 @@ impl App {
|
||||||
|
|
||||||
let mut resp = Response::builder()
|
let mut resp = Response::builder()
|
||||||
.status(res.status)
|
.status(res.status)
|
||||||
.typed_header(headers::AcceptRanges::bytes())
|
.typed_header(headers::AcceptRanges::bytes());
|
||||||
.typed_header(headers::LastModified::from(entry.last_modified));
|
|
||||||
if let Some(mime) = res.mime {
|
if let Some(mime) = res.mime {
|
||||||
resp = resp.typed_header(headers::ContentType::from(mime));
|
resp = resp.typed_header(headers::ContentType::from(mime));
|
||||||
}
|
}
|
||||||
|
if let Some(last_mod) = entry.last_modified {
|
||||||
|
resp = resp.typed_header(headers::LastModified::from(last_mod));
|
||||||
|
}
|
||||||
|
|
||||||
// handle if-(un)modified queries
|
// handle if-(un)modified queries
|
||||||
|
if let Some(modified) = entry.last_modified {
|
||||||
if let Some(if_unmodified_since) = hdrs.typed_get::<headers::IfUnmodifiedSince>() {
|
if let Some(if_unmodified_since) = hdrs.typed_get::<headers::IfUnmodifiedSince>() {
|
||||||
if !if_unmodified_since.precondition_passes(entry.last_modified) {
|
if !if_unmodified_since.precondition_passes(modified) {
|
||||||
return Ok(resp
|
return Ok(resp
|
||||||
.status(StatusCode::PRECONDITION_FAILED)
|
.status(StatusCode::PRECONDITION_FAILED)
|
||||||
.body(Body::empty())?);
|
.body(Body::empty())?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(if_modified_since) = hdrs.typed_get::<headers::IfModifiedSince>() {
|
if let Some(if_modified_since) = hdrs.typed_get::<headers::IfModifiedSince>() {
|
||||||
if !if_modified_since.is_modified(entry.last_modified) {
|
if !if_modified_since.is_modified(modified) {
|
||||||
return Ok(resp.status(StatusCode::NOT_MODIFIED).body(Body::empty())?);
|
return Ok(resp.status(StatusCode::NOT_MODIFIED).body(Body::empty())?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let zip_file = File::open(&zip_path).await?;
|
let zip_file = File::open(&zip_path).await?;
|
||||||
let range = hdrs.typed_get::<headers::Range>();
|
let range = hdrs.typed_get::<headers::Range>();
|
||||||
|
@ -367,7 +352,7 @@ impl App {
|
||||||
Host(host): Host,
|
Host(host): Host,
|
||||||
) -> Result<Json<Vec<Artifact>>> {
|
) -> Result<Json<Vec<Artifact>>> {
|
||||||
let subdomain = util::get_subdomain(&host, &state.i.cfg.load().root_domain)?;
|
let subdomain = util::get_subdomain(&host, &state.i.cfg.load().root_domain)?;
|
||||||
let query = Query::from_subdomain(subdomain)?.into_runquery();
|
let query = Query::from_subdomain(subdomain)?;
|
||||||
let artifacts = state.i.api.list(&query).await?;
|
let artifacts = state.i.api.list(&query).await?;
|
||||||
Ok(Json(artifacts))
|
Ok(Json(artifacts))
|
||||||
}
|
}
|
||||||
|
@ -378,25 +363,37 @@ impl App {
|
||||||
Host(host): Host,
|
Host(host): Host,
|
||||||
) -> Result<Json<Artifact>> {
|
) -> Result<Json<Artifact>> {
|
||||||
let subdomain = util::get_subdomain(&host, &state.i.cfg.load().root_domain)?;
|
let subdomain = util::get_subdomain(&host, &state.i.cfg.load().root_domain)?;
|
||||||
let query = Query::from_subdomain(subdomain)?.try_into_artifactquery()?;
|
let query = Query::from_subdomain(subdomain)?;
|
||||||
|
|
||||||
|
if query.artifact.is_none() {
|
||||||
|
return Err(Error::BadRequest("no artifact specified".into()));
|
||||||
|
}
|
||||||
|
|
||||||
let artifact = state.i.api.fetch(&query).await?;
|
let artifact = state.i.api.fetch(&query).await?;
|
||||||
Ok(Json(artifact))
|
match artifact {
|
||||||
|
ArtifactOrRun::Artifact(artifact) => Ok(Json(artifact)),
|
||||||
|
ArtifactOrRun::Run(_) => unreachable!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// API endpoint to get a file listing
|
/// API endpoint to get a file listing
|
||||||
async fn get_files(
|
async fn get_files(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
Host(host): Host,
|
Host(host): Host,
|
||||||
request: Request,
|
|
||||||
) -> Result<Json<Vec<IndexEntry>>> {
|
) -> Result<Json<Vec<IndexEntry>>> {
|
||||||
let subdomain = util::get_subdomain(&host, &state.i.cfg.load().root_domain)?;
|
let subdomain = util::get_subdomain(&host, &state.i.cfg.load().root_domain)?;
|
||||||
let ip = util::get_ip_address(&request, state.i.cfg.load().real_ip_header.as_deref())?;
|
let query = Query::from_subdomain(subdomain)?;
|
||||||
let query = Query::from_subdomain(subdomain)?.try_into_artifactquery()?;
|
|
||||||
let entry_res = state.i.cache.get_entry(&state.i.api, &query, &ip).await?;
|
if query.artifact.is_none() {
|
||||||
if entry_res.downloaded {
|
return Err(Error::BadRequest("no artifact specified".into()));
|
||||||
state.garbage_collect();
|
|
||||||
}
|
}
|
||||||
let files = entry_res.entry.get_files();
|
|
||||||
|
let res = state.i.cache.get_entry(&state.i.api, &query).await?;
|
||||||
|
let entry = match res {
|
||||||
|
GetEntryResult::Entry { entry, .. } => entry,
|
||||||
|
GetEntryResult::Artifacts(_) => unreachable!(),
|
||||||
|
};
|
||||||
|
let files = entry.get_files();
|
||||||
Ok(Json(files))
|
Ok(Json(files))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,14 +407,4 @@ impl AppState {
|
||||||
i: Arc::new(AppInner { cfg, cache, api }),
|
i: Arc::new(AppInner { cfg, cache, api }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run garbage collection in the background if necessary
|
|
||||||
pub fn garbage_collect(&self) {
|
|
||||||
let state = self.clone();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
if let Err(e) = state.i.cache.garbage_collect().await {
|
|
||||||
tracing::error!("error during garbage collect: {e}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,34 @@
|
||||||
//! API-Client to fetch CI artifacts from Github and Forgejo
|
//! API-Client to fetch CI artifacts from Github and Forgejo
|
||||||
|
|
||||||
use std::path::Path;
|
use std::{fs::File, io::Cursor, path::Path};
|
||||||
|
|
||||||
use futures_lite::StreamExt;
|
|
||||||
use http::header;
|
use http::header;
|
||||||
use quick_cache::sync::Cache as QuickCache;
|
|
||||||
use reqwest::{Client, ClientBuilder, IntoUrl, RequestBuilder, Url};
|
use reqwest::{Client, ClientBuilder, IntoUrl, RequestBuilder, Url};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tokio::{fs::File, io::AsyncWriteExt};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
query::{ArtifactQuery, QueryData},
|
query::Query,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ArtifactApi {
|
pub struct ArtifactApi {
|
||||||
http: Client,
|
http: Client,
|
||||||
cfg: Config,
|
cfg: Config,
|
||||||
qc: QuickCache<String, Vec<Artifact>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct Artifact {
|
pub struct Artifact {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
pub expired: bool,
|
pub expired: bool,
|
||||||
/// Artifact download URL used by the server
|
|
||||||
pub download_url: String,
|
pub download_url: String,
|
||||||
/// Artifact download URL shown to the user. If None, download_url is used
|
}
|
||||||
///
|
|
||||||
/// GitHub uses different download URLs for their API and their frontend.
|
pub enum ArtifactOrRun {
|
||||||
pub user_download_url: Option<String>,
|
Artifact(Artifact),
|
||||||
|
Run(Vec<Artifact>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -63,24 +59,20 @@ enum ForgejoArtifactStatus {
|
||||||
Expired,
|
Expired,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GithubArtifact {
|
impl From<GithubArtifact> for Artifact {
|
||||||
fn into_artifact<T>(self, query: &QueryData<T>) -> Artifact {
|
fn from(value: GithubArtifact) -> Self {
|
||||||
Artifact {
|
Self {
|
||||||
id: self.id,
|
id: value.id,
|
||||||
name: self.name,
|
name: value.name,
|
||||||
size: self.size_in_bytes,
|
size: value.size_in_bytes,
|
||||||
expired: self.expired,
|
expired: value.expired,
|
||||||
download_url: self.archive_download_url,
|
download_url: value.archive_download_url,
|
||||||
user_download_url: Some(format!(
|
|
||||||
"https://github.com/{}/{}/actions/runs/{}/artifacts/{}",
|
|
||||||
query.user, query.repo, query.run, self.id
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ForgejoArtifact {
|
impl ForgejoArtifact {
|
||||||
fn into_artifact<T>(self, id: u64, query: &QueryData<T>) -> Artifact {
|
fn into_artifact(self, id: u64, query: &Query) -> Artifact {
|
||||||
Artifact {
|
Artifact {
|
||||||
download_url: format!(
|
download_url: format!(
|
||||||
"https://{}/{}/{}/actions/runs/{}/artifacts/{}",
|
"https://{}/{}/{}/actions/runs/{}/artifacts/{}",
|
||||||
|
@ -90,7 +82,6 @@ impl ForgejoArtifact {
|
||||||
name: self.name,
|
name: self.name,
|
||||||
size: self.size,
|
size: self.size,
|
||||||
expired: matches!(self.status, ForgejoArtifactStatus::Expired),
|
expired: matches!(self.status, ForgejoArtifactStatus::Expired),
|
||||||
user_download_url: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,36 +97,35 @@ impl ArtifactApi {
|
||||||
))
|
))
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
qc: QuickCache::new(cfg.load().mem_cache_size),
|
|
||||||
cfg,
|
cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list<T>(&self, query: &QueryData<T>) -> Result<Vec<Artifact>> {
|
pub async fn list(&self, query: &Query) -> Result<Vec<Artifact>> {
|
||||||
let subdomain = query.subdomain_with_artifact(None);
|
|
||||||
self.qc
|
|
||||||
.get_or_insert_async(&subdomain, async {
|
|
||||||
if query.is_github() {
|
if query.is_github() {
|
||||||
self.list_github(query).await
|
self.list_github(query).await
|
||||||
} else {
|
} else {
|
||||||
self.list_forgejo(query).await
|
self.list_forgejo(query).await
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch(&self, query: &ArtifactQuery) -> Result<Artifact> {
|
pub async fn fetch(&self, query: &Query) -> Result<ArtifactOrRun> {
|
||||||
if query.is_github() {
|
if query.is_github() {
|
||||||
self.fetch_github(query).await
|
self.fetch_github(query).await
|
||||||
} else {
|
} else {
|
||||||
// Forgejo currently has no API for fetching single artifacts
|
// Forgejo currently has no API for fetching single artifacts
|
||||||
let mut artifacts = self.list_forgejo(query).await?;
|
let mut artifacts = self.list_forgejo(query).await?;
|
||||||
|
|
||||||
let i = usize::try_from(query.artifact)?;
|
match query.artifact {
|
||||||
|
Some(artifact) => {
|
||||||
|
let i = usize::try_from(artifact)?;
|
||||||
if i == 0 || i > artifacts.len() {
|
if i == 0 || i > artifacts.len() {
|
||||||
return Err(Error::NotFound("artifact".into()));
|
return Err(Error::NotFound("artifact".into()));
|
||||||
}
|
}
|
||||||
Ok(artifacts.swap_remove(i - 1))
|
Ok(ArtifactOrRun::Artifact(artifacts.swap_remove(i - 1)))
|
||||||
|
}
|
||||||
|
None => Ok(ArtifactOrRun::Run(artifacts)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,11 +136,7 @@ impl ArtifactApi {
|
||||||
|
|
||||||
let lim = self.cfg.load().max_artifact_size;
|
let lim = self.cfg.load().max_artifact_size;
|
||||||
let check_lim = |size: u64| {
|
let check_lim = |size: u64| {
|
||||||
if lim.is_some_and(|lim| {
|
if lim.is_some_and(|lim| u32::try_from(size).map(|size| size > lim).unwrap_or(true)) {
|
||||||
u32::try_from(size)
|
|
||||||
.map(|size| size > lim.into())
|
|
||||||
.unwrap_or(true)
|
|
||||||
}) {
|
|
||||||
Err(Error::BadRequest(
|
Err(Error::BadRequest(
|
||||||
format!(
|
format!(
|
||||||
"artifact too large (size: {}, limit: {})",
|
"artifact too large (size: {}, limit: {})",
|
||||||
|
@ -179,23 +165,15 @@ impl ArtifactApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
let tmp_path = path.with_extension(format!("tmp.{:x}", rand::random::<u32>()));
|
let tmp_path = path.with_extension(format!("tmp.{:x}", rand::random::<u32>()));
|
||||||
|
let mut file = File::create(&tmp_path)?;
|
||||||
{
|
let mut content = Cursor::new(resp.bytes().await?);
|
||||||
let mut file = File::create(&tmp_path).await?;
|
std::io::copy(&mut content, &mut file)?;
|
||||||
let mut stream = resp.bytes_stream();
|
std::fs::rename(&tmp_path, path)?;
|
||||||
while let Some(item) = stream.next().await {
|
|
||||||
let mut chunk = item?;
|
|
||||||
file.write_all_buf(&mut chunk).await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tokio::fs::write(path.with_extension("name"), &artifact.name).await?;
|
|
||||||
tokio::fs::rename(&tmp_path, path).await?;
|
|
||||||
|
|
||||||
tracing::info!("Downloaded artifact from {}", artifact.download_url);
|
tracing::info!("Downloaded artifact from {}", artifact.download_url);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_forgejo<T>(&self, query: &QueryData<T>) -> Result<Vec<Artifact>> {
|
async fn list_forgejo(&self, query: &Query) -> Result<Vec<Artifact>> {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://{}/{}/{}/actions/runs/{}/artifacts",
|
"https://{}/{}/{}/actions/runs/{}/artifacts",
|
||||||
query.host, query.user, query.repo, query.run
|
query.host, query.user, query.repo, query.run
|
||||||
|
@ -220,7 +198,7 @@ impl ArtifactApi {
|
||||||
Ok(artifacts)
|
Ok(artifacts)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_github<T>(&self, query: &QueryData<T>) -> Result<Vec<Artifact>> {
|
async fn list_github(&self, query: &Query) -> Result<Vec<Artifact>> {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://api.github.com/repos/{}/{}/actions/runs/{}/artifacts",
|
"https://api.github.com/repos/{}/{}/actions/runs/{}/artifacts",
|
||||||
query.user, query.repo, query.run
|
query.user, query.repo, query.run
|
||||||
|
@ -234,17 +212,15 @@ impl ArtifactApi {
|
||||||
.json::<ArtifactsWrap<GithubArtifact>>()
|
.json::<ArtifactsWrap<GithubArtifact>>()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(resp
|
Ok(resp.artifacts.into_iter().map(Artifact::from).collect())
|
||||||
.artifacts
|
|
||||||
.into_iter()
|
|
||||||
.map(|a| a.into_artifact(query))
|
|
||||||
.collect())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_github(&self, query: &ArtifactQuery) -> Result<Artifact> {
|
async fn fetch_github(&self, query: &Query) -> Result<ArtifactOrRun> {
|
||||||
|
match query.artifact {
|
||||||
|
Some(artifact) => {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://api.github.com/repos/{}/{}/actions/artifacts/{}",
|
"https://api.github.com/repos/{}/{}/actions/artifacts/{}",
|
||||||
query.user, query.repo, query.artifact
|
query.user, query.repo, artifact
|
||||||
);
|
);
|
||||||
|
|
||||||
let artifact = self
|
let artifact = self
|
||||||
|
@ -254,7 +230,10 @@ impl ArtifactApi {
|
||||||
.error_for_status()?
|
.error_for_status()?
|
||||||
.json::<GithubArtifact>()
|
.json::<GithubArtifact>()
|
||||||
.await?;
|
.await?;
|
||||||
Ok(artifact.into_artifact(query))
|
Ok(ArtifactOrRun::Artifact(artifact.into()))
|
||||||
|
}
|
||||||
|
None => Ok(ArtifactOrRun::Run(self.list_github(query).await?)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_github<U: IntoUrl>(&self, url: U) -> RequestBuilder {
|
fn get_github<U: IntoUrl>(&self, url: U) -> RequestBuilder {
|
||||||
|
@ -269,39 +248,57 @@ impl ArtifactApi {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{config::Config, query::ArtifactQuery};
|
use crate::{config::Config, query::Query};
|
||||||
|
|
||||||
use super::ArtifactApi;
|
use super::{ArtifactApi, ArtifactOrRun};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn fetch_forgejo() {
|
async fn fetch_forgejo() {
|
||||||
let query = ArtifactQuery {
|
let query = Query {
|
||||||
host: "code.thetadev.de".to_owned(),
|
host: "code.thetadev.de".to_owned(),
|
||||||
user: "HSA".to_owned(),
|
user: "HSA".to_owned(),
|
||||||
repo: "Visitenbuch".to_owned(),
|
repo: "Visitenbuch".to_owned(),
|
||||||
run: 32,
|
run: 32,
|
||||||
artifact: 1,
|
artifact: Some(1),
|
||||||
};
|
};
|
||||||
let api = ArtifactApi::new(Config::default());
|
let api = ArtifactApi::new(Config::default());
|
||||||
let res = api.fetch(&query).await.unwrap();
|
let res = api.fetch(&query).await.unwrap();
|
||||||
|
|
||||||
|
if let ArtifactOrRun::Artifact(res) = res {
|
||||||
|
assert_eq!(res.name, "playwright-report");
|
||||||
|
assert_eq!(
|
||||||
|
res.download_url,
|
||||||
|
"https://code.thetadev.de/HSA/Visitenbuch/actions/runs/32/artifacts/playwright-report"
|
||||||
|
);
|
||||||
assert_eq!(res.id, 1);
|
assert_eq!(res.id, 1);
|
||||||
assert_eq!(res.size, 574292);
|
assert_eq!(res.size, 574292);
|
||||||
|
} else {
|
||||||
|
panic!("got run");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn fetch_github() {
|
async fn fetch_github() {
|
||||||
let query = ArtifactQuery {
|
let query = Query {
|
||||||
host: "github.com".to_owned(),
|
host: "github.com".to_owned(),
|
||||||
user: "actions".to_owned(),
|
user: "actions".to_owned(),
|
||||||
repo: "upload-artifact".to_owned(),
|
repo: "upload-artifact".to_owned(),
|
||||||
run: 8805345396,
|
run: 8805345396,
|
||||||
artifact: 1440556464,
|
artifact: Some(1440556464),
|
||||||
};
|
};
|
||||||
let api = ArtifactApi::new(Config::default());
|
let api = ArtifactApi::new(Config::default());
|
||||||
let res = api.fetch(&query).await.unwrap();
|
let res = api.fetch(&query).await.unwrap();
|
||||||
|
|
||||||
|
if let ArtifactOrRun::Artifact(res) = res {
|
||||||
|
assert_eq!(res.name, "Artifact-Wildcard-macos-latest");
|
||||||
|
assert_eq!(
|
||||||
|
res.download_url,
|
||||||
|
"https://api.github.com/repos/actions/upload-artifact/actions/artifacts/1440556464/zip"
|
||||||
|
);
|
||||||
assert_eq!(res.id, 1440556464);
|
assert_eq!(res.id, 1440556464);
|
||||||
assert_eq!(res.size, 334);
|
assert_eq!(res.size, 334);
|
||||||
|
} else {
|
||||||
|
panic!("got run");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
190
src/cache.rs
190
src/cache.rs
|
@ -1,16 +1,12 @@
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap},
|
||||||
fs::FileTimes,
|
|
||||||
net::IpAddr,
|
|
||||||
num::{NonZeroU32, NonZeroUsize},
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_zip::{tokio::read::fs::ZipFileReader, Compression};
|
use async_zip::{tokio::read::fs::ZipFileReader, Compression};
|
||||||
use governor::{Quota, RateLimiter};
|
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
use path_macro::path;
|
use path_macro::path;
|
||||||
|
@ -19,29 +15,21 @@ use serde::Serialize;
|
||||||
use serde_hex::{SerHex, Strict};
|
use serde_hex::{SerHex, Strict};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
artifact_api::ArtifactApi,
|
artifact_api::{Artifact, ArtifactApi, ArtifactOrRun},
|
||||||
config::Config,
|
config::Config,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
query::ArtifactQuery,
|
query::Query,
|
||||||
util::{self, IgnoreFileNotFound},
|
util,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Cache {
|
pub struct Cache {
|
||||||
cfg: Config,
|
cfg: Config,
|
||||||
qc: QuickCache<String, Arc<CacheEntry>>,
|
qc: QuickCache<[u8; 16], Arc<CacheEntry>>,
|
||||||
lim_download: Option<
|
|
||||||
governor::DefaultKeyedRateLimiter<
|
|
||||||
IpAddr,
|
|
||||||
governor::middleware::NoOpMiddleware<governor::clock::QuantaInstant>,
|
|
||||||
>,
|
|
||||||
>,
|
|
||||||
lim_gc: governor::DefaultDirectRateLimiter,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CacheEntry {
|
pub struct CacheEntry {
|
||||||
pub files: HashMap<String, FileEntry>,
|
pub files: HashMap<String, FileEntry>,
|
||||||
pub name: String,
|
pub last_modified: Option<SystemTime>,
|
||||||
pub last_modified: SystemTime,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -53,10 +41,12 @@ pub struct FileEntry {
|
||||||
pub compression: Compression,
|
pub compression: Compression,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GetEntryResult {
|
pub enum GetEntryResult {
|
||||||
pub entry: Arc<CacheEntry>,
|
Entry {
|
||||||
pub zip_path: PathBuf,
|
entry: Arc<CacheEntry>,
|
||||||
pub downloaded: bool,
|
zip_path: PathBuf,
|
||||||
|
},
|
||||||
|
Artifacts(Vec<Artifact>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum GetFileResult {
|
pub enum GetFileResult {
|
||||||
|
@ -88,40 +78,33 @@ pub struct Listing {
|
||||||
pub struct ListingEntry {
|
pub struct ListingEntry {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub size: Size,
|
pub size: u32,
|
||||||
pub crc32: String,
|
pub crc32: String,
|
||||||
pub is_dir: bool,
|
pub is_dir: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Size(pub u32);
|
|
||||||
|
|
||||||
impl Cache {
|
impl Cache {
|
||||||
pub fn new(cfg: Config) -> Self {
|
pub fn new(cfg: Config) -> Self {
|
||||||
Self {
|
Self {
|
||||||
qc: QuickCache::new(cfg.load().mem_cache_size),
|
|
||||||
lim_download: cfg
|
|
||||||
.load()
|
|
||||||
.limit_artifacts_per_min
|
|
||||||
.map(|lim| RateLimiter::keyed(Quota::per_minute(lim))),
|
|
||||||
lim_gc: RateLimiter::direct(Quota::per_hour(NonZeroU32::MIN)),
|
|
||||||
cfg,
|
cfg,
|
||||||
|
qc: QuickCache::new(50),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_entry(
|
pub fn get_path(&self, query: &Query) -> PathBuf {
|
||||||
&self,
|
path!(self.cfg.load().cache_dir / format!("{}.zip", hex::encode(query.siphash())))
|
||||||
api: &ArtifactApi,
|
|
||||||
query: &ArtifactQuery,
|
|
||||||
ip: &IpAddr,
|
|
||||||
) -> Result<GetEntryResult> {
|
|
||||||
let subdomain = query.subdomain();
|
|
||||||
let zip_path = path!(self.cfg.load().cache_dir / format!("{subdomain}.zip"));
|
|
||||||
let downloaded = !zip_path.is_file();
|
|
||||||
if downloaded {
|
|
||||||
let artifact = api.fetch(query).await?;
|
|
||||||
if let Some(limiter) = &self.lim_download {
|
|
||||||
limiter.check_key(ip)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_entry(&self, api: &ArtifactApi, query: &Query) -> Result<GetEntryResult> {
|
||||||
|
if query.artifact.is_some() {
|
||||||
|
let hash = query.siphash();
|
||||||
|
let zip_path = path!(self.cfg.load().cache_dir / format!("{}.zip", hex::encode(hash)));
|
||||||
|
if !zip_path.is_file() {
|
||||||
|
let artifact = api.fetch(query).await?;
|
||||||
|
let artifact = match artifact {
|
||||||
|
ArtifactOrRun::Artifact(artifact) => artifact,
|
||||||
|
ArtifactOrRun::Run(_) => unreachable!(),
|
||||||
|
};
|
||||||
api.download(&artifact, &zip_path).await?;
|
api.download(&artifact, &zip_path).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,102 +112,36 @@ impl Cache {
|
||||||
.cfg
|
.cfg
|
||||||
.load()
|
.load()
|
||||||
.zip_timeout_ms
|
.zip_timeout_ms
|
||||||
.map(|t| Duration::from_millis(u32::from(t).into()));
|
.map(|t| Duration::from_millis(t.into()));
|
||||||
let max_file_count = self.cfg.load().max_file_count;
|
|
||||||
let mut entry = self
|
let mut entry = self
|
||||||
.qc
|
.qc
|
||||||
.get_or_insert_async(&subdomain, async {
|
.get_or_insert_async(&hash, async {
|
||||||
Ok::<_, Error>(Arc::new(
|
Ok::<_, Error>(Arc::new(CacheEntry::new(&zip_path, timeout).await?))
|
||||||
CacheEntry::new(&zip_path, timeout, max_file_count, query.artifact).await?,
|
|
||||||
))
|
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Verify if the cached entry is fresh
|
// Verify if the cached entry is fresh
|
||||||
let metadata = tokio::fs::metadata(&zip_path).await?;
|
let meta = tokio::fs::metadata(&zip_path).await?;
|
||||||
let modified = metadata
|
if meta.modified().ok() != entry.last_modified {
|
||||||
.modified()
|
|
||||||
.map_err(|_| Error::Internal("no file modified time".into()))?;
|
|
||||||
let accessed = metadata
|
|
||||||
.accessed()
|
|
||||||
.map_err(|_| Error::Internal("no file accessed time".into()))?;
|
|
||||||
if modified != entry.last_modified {
|
|
||||||
tracing::info!("cached file {zip_path:?} changed");
|
tracing::info!("cached file {zip_path:?} changed");
|
||||||
entry = Arc::new(
|
entry = Arc::new(CacheEntry::new(&zip_path, timeout).await?);
|
||||||
CacheEntry::new(&zip_path, timeout, max_file_count, query.artifact).await?,
|
self.qc.insert(hash, entry.clone());
|
||||||
);
|
|
||||||
self.qc.insert(subdomain, entry.clone());
|
|
||||||
}
|
|
||||||
// Update last_accessed time if older than 30min
|
|
||||||
// some systems may have access time disabled and we need it to keep track of stale artifacts
|
|
||||||
let now = SystemTime::now();
|
|
||||||
if now
|
|
||||||
.duration_since(accessed)
|
|
||||||
.map_err(|e| Error::Internal(e.to_string().into()))?
|
|
||||||
> Duration::from_secs(1800)
|
|
||||||
{
|
|
||||||
let file = std::fs::File::open(&zip_path)?;
|
|
||||||
file.set_times(FileTimes::new().set_accessed(now))?;
|
|
||||||
}
|
}
|
||||||
|
Ok(GetEntryResult::Entry { entry, zip_path })
|
||||||
|
} else {
|
||||||
|
let run = api.fetch(query).await?;
|
||||||
|
let artifacts = match run {
|
||||||
|
ArtifactOrRun::Artifact(_) => unreachable!(),
|
||||||
|
ArtifactOrRun::Run(run) => run,
|
||||||
|
};
|
||||||
|
|
||||||
Ok(GetEntryResult {
|
Ok(GetEntryResult::Artifacts(artifacts))
|
||||||
entry,
|
|
||||||
zip_path,
|
|
||||||
downloaded,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn garbage_collect(&self) -> Result<()> {
|
|
||||||
if self.lim_gc.check().is_err() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
tracing::info!("starting garbage collect");
|
|
||||||
|
|
||||||
let now = SystemTime::now();
|
|
||||||
let max_age = Duration::from_secs(u64::from(u32::from(self.cfg.load().max_age_h)) * 3600);
|
|
||||||
|
|
||||||
let mut n = 0;
|
|
||||||
let mut rd = tokio::fs::read_dir(&self.cfg.load().cache_dir).await?;
|
|
||||||
while let Some(entry) = rd.next_entry().await? {
|
|
||||||
if entry.file_type().await?.is_file()
|
|
||||||
&& entry.path().extension().is_some_and(|ext| ext == "zip")
|
|
||||||
{
|
|
||||||
let accessed = entry
|
|
||||||
.metadata()
|
|
||||||
.await?
|
|
||||||
.accessed()
|
|
||||||
.map_err(|_| Error::Internal("no file accessed time".into()))?;
|
|
||||||
if now
|
|
||||||
.duration_since(accessed)
|
|
||||||
.map_err(|e| Error::Internal(e.to_string().into()))?
|
|
||||||
> max_age
|
|
||||||
{
|
|
||||||
let path = entry.path();
|
|
||||||
if let Some(name) = path.file_stem().and_then(|s| s.to_str()) {
|
|
||||||
self.qc.remove(name);
|
|
||||||
}
|
|
||||||
tokio::fs::remove_file(path.with_extension("name"))
|
|
||||||
.await
|
|
||||||
.ignore_file_not_found()?;
|
|
||||||
tokio::fs::remove_file(&path)
|
|
||||||
.await
|
|
||||||
.ignore_file_not_found()?;
|
|
||||||
n += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tracing::info!("garbage collect finished: {n} artifacts removed");
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CacheEntry {
|
impl CacheEntry {
|
||||||
async fn new(
|
async fn new(zip_path: &Path, timeout: Option<Duration>) -> Result<Self> {
|
||||||
zip_path: &Path,
|
|
||||||
timeout: Option<Duration>,
|
|
||||||
max_file_count: Option<NonZeroUsize>,
|
|
||||||
artifact: u64,
|
|
||||||
) -> Result<Self> {
|
|
||||||
let meta = tokio::fs::metadata(&zip_path).await?;
|
let meta = tokio::fs::metadata(&zip_path).await?;
|
||||||
let zip_fut = ZipFileReader::new(&zip_path);
|
let zip_fut = ZipFileReader::new(&zip_path);
|
||||||
let zip = match timeout {
|
let zip = match timeout {
|
||||||
|
@ -232,16 +149,6 @@ impl CacheEntry {
|
||||||
None => zip_fut.await?,
|
None => zip_fut.await?,
|
||||||
};
|
};
|
||||||
|
|
||||||
if max_file_count.is_some_and(|lim| zip.file().entries().len() > lim.into()) {
|
|
||||||
return Err(Error::BadRequest("artifact contains too many files".into()));
|
|
||||||
}
|
|
||||||
|
|
||||||
let name_path = zip_path.with_extension("name");
|
|
||||||
let name = tokio::fs::read_to_string(name_path)
|
|
||||||
.await
|
|
||||||
.ok()
|
|
||||||
.unwrap_or_else(|| format!("A{artifact}"));
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
files: zip
|
files: zip
|
||||||
.file()
|
.file()
|
||||||
|
@ -260,10 +167,7 @@ impl CacheEntry {
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
name,
|
last_modified: meta.modified().ok(),
|
||||||
last_modified: meta
|
|
||||||
.modified()
|
|
||||||
.map_err(|_| Error::Internal("no file modified time".into()))?,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +279,7 @@ impl CacheEntry {
|
||||||
directories.push(ListingEntry {
|
directories.push(ListingEntry {
|
||||||
name: n.to_owned(),
|
name: n.to_owned(),
|
||||||
url: format!("{n}{path}"),
|
url: format!("{n}{path}"),
|
||||||
size: Size(0),
|
size: 0,
|
||||||
crc32: "-".to_string(),
|
crc32: "-".to_string(),
|
||||||
is_dir: true,
|
is_dir: true,
|
||||||
});
|
});
|
||||||
|
@ -383,7 +287,7 @@ impl CacheEntry {
|
||||||
files.push(ListingEntry {
|
files.push(ListingEntry {
|
||||||
name: n.to_owned(),
|
name: n.to_owned(),
|
||||||
url: format!("{n}{path}"),
|
url: format!("{n}{path}"),
|
||||||
size: Size(entry.uncompressed_size),
|
size: entry.uncompressed_size,
|
||||||
crc32: hex::encode(entry.crc32.to_le_bytes()),
|
crc32: hex::encode(entry.crc32.to_le_bytes()),
|
||||||
is_dir: false,
|
is_dir: false,
|
||||||
});
|
});
|
||||||
|
@ -393,9 +297,9 @@ impl CacheEntry {
|
||||||
// Sort by size
|
// Sort by size
|
||||||
if col == b'S' {
|
if col == b'S' {
|
||||||
if rev {
|
if rev {
|
||||||
files.sort_by(|a, b| b.size.0.cmp(&a.size.0));
|
files.sort_by(|a, b| b.size.cmp(&a.size));
|
||||||
} else {
|
} else {
|
||||||
files.sort_by_key(|f| f.size.0);
|
files.sort_by_key(|f| f.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use std::{
|
use std::{
|
||||||
num::{NonZeroU32, NonZeroUsize},
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
@ -21,40 +20,14 @@ struct ConfigInner {
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct ConfigData {
|
pub struct ConfigData {
|
||||||
/// Folder where the downloaded artifacts are stored
|
|
||||||
pub cache_dir: PathBuf,
|
pub cache_dir: PathBuf,
|
||||||
/// Root domain under which the server is available
|
|
||||||
///
|
|
||||||
/// The individual artifacts are served under `<subdomain>.<root_domain>`
|
|
||||||
pub root_domain: String,
|
pub root_domain: String,
|
||||||
/// Set to true if the server is not available under HTTPS
|
|
||||||
pub no_https: bool,
|
pub no_https: bool,
|
||||||
/// Maximum artifact (ZIP) size to be downloaded
|
pub max_artifact_size: Option<u32>,
|
||||||
pub max_artifact_size: Option<NonZeroU32>,
|
pub max_file_size: Option<u32>,
|
||||||
/// Maximum file size to be served
|
pub max_age_h: Option<u16>,
|
||||||
pub max_file_size: Option<NonZeroU32>,
|
pub zip_timeout_ms: Option<u32>,
|
||||||
/// Maximum file count within a ZIP file
|
|
||||||
pub max_file_count: Option<NonZeroUsize>,
|
|
||||||
/// Maximum age in hours after which artifacts are deleted
|
|
||||||
pub max_age_h: NonZeroU32,
|
|
||||||
/// Maximum time in milliseconds for reading a zip file index
|
|
||||||
pub zip_timeout_ms: Option<NonZeroU32>,
|
|
||||||
/// GitHub API token for downloading GitHub artifacts
|
|
||||||
///
|
|
||||||
/// Using a fine-grained token with public read permissions is recommended.
|
|
||||||
pub github_token: Option<String>,
|
pub github_token: Option<String>,
|
||||||
/// Number of artifact indexes to keep in memory
|
|
||||||
pub mem_cache_size: usize,
|
|
||||||
/// Get the client IP address from a HTTP request header
|
|
||||||
///
|
|
||||||
/// If Artifactview is exposed to the network directly, this option
|
|
||||||
/// has to be unset. If you are using a reverse proxy the proxy needs to
|
|
||||||
/// be configured to send the actual client IP as a request header.
|
|
||||||
///
|
|
||||||
/// For most proxies this header is `x-forwarded-for`.
|
|
||||||
pub real_ip_header: Option<String>,
|
|
||||||
/// Limit the amount of downloaded artifacts per IP address and minute
|
|
||||||
pub limit_artifacts_per_min: Option<NonZeroU32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ConfigData {
|
impl Default for ConfigData {
|
||||||
|
@ -63,15 +36,11 @@ impl Default for ConfigData {
|
||||||
cache_dir: Path::new("/tmp/artifactview").into(),
|
cache_dir: Path::new("/tmp/artifactview").into(),
|
||||||
root_domain: "localhost:3000".to_string(),
|
root_domain: "localhost:3000".to_string(),
|
||||||
no_https: false,
|
no_https: false,
|
||||||
max_artifact_size: Some(NonZeroU32::new(100_000_000).unwrap()),
|
max_artifact_size: Some(100_000_000),
|
||||||
max_file_size: Some(NonZeroU32::new(100_000_000).unwrap()),
|
max_file_size: Some(100_000_000),
|
||||||
max_file_count: Some(NonZeroUsize::new(10_000).unwrap()),
|
max_age_h: Some(12),
|
||||||
max_age_h: NonZeroU32::new(12).unwrap(),
|
zip_timeout_ms: Some(1000),
|
||||||
zip_timeout_ms: Some(NonZeroU32::new(1000).unwrap()),
|
|
||||||
github_token: None,
|
github_token: None,
|
||||||
mem_cache_size: 50,
|
|
||||||
real_ip_header: None,
|
|
||||||
limit_artifacts_per_min: Some(NonZeroU32::new(5).unwrap()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@ pub enum Error {
|
||||||
Timeout(#[from] tokio::time::error::Elapsed),
|
Timeout(#[from] tokio::time::error::Elapsed),
|
||||||
#[error("method not allowed")]
|
#[error("method not allowed")]
|
||||||
MethodNotAllowed,
|
MethodNotAllowed,
|
||||||
#[error("you are fetching new artifacts too fast, please wait a minute and try again")]
|
|
||||||
Ratelimit,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<reqwest::Error> for Error {
|
impl From<reqwest::Error> for Error {
|
||||||
|
@ -62,12 +60,6 @@ impl From<url::ParseError> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<governor::NotUntil<governor::clock::QuantaInstant>> for Error {
|
|
||||||
fn from(_: governor::NotUntil<governor::clock::QuantaInstant>) -> Self {
|
|
||||||
Self::Ratelimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
pub fn status(&self) -> StatusCode {
|
pub fn status(&self) -> StatusCode {
|
||||||
match self {
|
match self {
|
||||||
|
@ -75,7 +67,6 @@ impl Error {
|
||||||
Error::NotFound(_) | Error::Inaccessible | Error::Expired => StatusCode::NOT_FOUND,
|
Error::NotFound(_) | Error::Inaccessible | Error::Expired => StatusCode::NOT_FOUND,
|
||||||
Error::HttpClient(_, status) => *status,
|
Error::HttpClient(_, status) => *status,
|
||||||
Error::MethodNotAllowed => StatusCode::METHOD_NOT_ALLOWED,
|
Error::MethodNotAllowed => StatusCode::METHOD_NOT_ALLOWED,
|
||||||
Error::Ratelimit => StatusCode::TOO_MANY_REQUESTS,
|
|
||||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
133
src/query.rs
133
src/query.rs
|
@ -2,21 +2,13 @@ use std::{fmt::Write, hash::Hash};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::{Captures, Regex};
|
use regex::{Captures, Regex};
|
||||||
|
use siphasher::sip128::{Hasher128, SipHasher};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub enum Query {
|
|
||||||
Artifact(ArtifactQuery),
|
|
||||||
Run(RunQuery),
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type RunQuery = QueryData<()>;
|
|
||||||
pub type ArtifactQuery = QueryData<u64>;
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct QueryData<T> {
|
pub struct Query {
|
||||||
/// Forge host
|
/// Forge host
|
||||||
pub host: String,
|
pub host: String,
|
||||||
/// User/org name (case-insensitive)
|
/// User/org name (case-insensitive)
|
||||||
|
@ -25,8 +17,8 @@ pub struct QueryData<T> {
|
||||||
pub repo: String,
|
pub repo: String,
|
||||||
/// CI run id
|
/// CI run id
|
||||||
pub run: u64,
|
pub run: u64,
|
||||||
// Optional selected artifact
|
/// Artifact id (unique for every run)
|
||||||
pub artifact: T,
|
pub artifact: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static RE_REPO_NAME: Lazy<Regex> = Lazy::new(|| Regex::new("^[A-z0-9\\-_\\.]+$").unwrap());
|
static RE_REPO_NAME: Lazy<Regex> = Lazy::new(|| Regex::new("^[A-z0-9\\-_\\.]+$").unwrap());
|
||||||
|
@ -43,26 +35,15 @@ impl Query {
|
||||||
return Err(Error::InvalidUrl);
|
return Err(Error::InvalidUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
let host = decode_domain(segments[0], '.');
|
Ok(Self {
|
||||||
let user = decode_domain(segments[1], '-');
|
host: Self::decode_domain(segments[0], '.'),
|
||||||
let repo = decode_domain(segments[2], '-');
|
user: Self::decode_domain(segments[1], '-'),
|
||||||
let run = run_and_artifact[0].parse().ok().ok_or(Error::InvalidUrl)?;
|
repo: Self::decode_domain(segments[2], '-'),
|
||||||
|
run: run_and_artifact[0].parse().ok().ok_or(Error::InvalidUrl)?,
|
||||||
Ok(match run_and_artifact.get(1) {
|
artifact: match run_and_artifact.get(1) {
|
||||||
Some(x) => Self::Artifact(QueryData {
|
Some(x) => Some(x.parse().ok().ok_or(Error::InvalidUrl)?),
|
||||||
host,
|
None => None,
|
||||||
user,
|
},
|
||||||
repo,
|
|
||||||
run,
|
|
||||||
artifact: x.parse().ok().ok_or(Error::InvalidUrl)?,
|
|
||||||
}),
|
|
||||||
None => Self::Run(QueryData {
|
|
||||||
host,
|
|
||||||
user,
|
|
||||||
repo,
|
|
||||||
run,
|
|
||||||
artifact: (),
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,56 +78,25 @@ impl Query {
|
||||||
.and_then(|s| s.parse::<u64>().ok())
|
.and_then(|s| s.parse::<u64>().ok())
|
||||||
.ok_or(Error::BadRequest("no run ID".into()))?;
|
.ok_or(Error::BadRequest("no run ID".into()))?;
|
||||||
|
|
||||||
Ok(Self::Run(RunQuery {
|
Ok(Self {
|
||||||
host: host.to_owned(),
|
host: host.to_owned(),
|
||||||
user: user.to_owned(),
|
user: user.to_owned(),
|
||||||
repo: repo.to_owned(),
|
repo: repo.to_owned(),
|
||||||
run,
|
run,
|
||||||
artifact: (),
|
artifact: None,
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subdomain(&self) -> String {
|
pub fn subdomain(&self) -> String {
|
||||||
match self {
|
self.subdomain_with_artifact(self.artifact)
|
||||||
Query::Artifact(q) => q.subdomain(),
|
|
||||||
Query::Run(q) => q.subdomain(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_runquery(self) -> RunQuery {
|
|
||||||
match self {
|
|
||||||
Query::Artifact(q) => q.into_runquery(),
|
|
||||||
Query::Run(q) => q,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn try_into_artifactquery(self) -> Result<ArtifactQuery> {
|
|
||||||
match self {
|
|
||||||
Query::Artifact(q) => Ok(q),
|
|
||||||
Query::Run(_) => Err(Error::BadRequest("no artifact specified".into())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ArtifactQuery {
|
|
||||||
pub fn subdomain(&self) -> String {
|
|
||||||
self.subdomain_with_artifact(Some(self.artifact))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RunQuery {
|
|
||||||
pub fn subdomain(&self) -> String {
|
|
||||||
self.subdomain_with_artifact(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> QueryData<T> {
|
|
||||||
pub fn subdomain_with_artifact(&self, artifact: Option<u64>) -> String {
|
pub fn subdomain_with_artifact(&self, artifact: Option<u64>) -> String {
|
||||||
let mut res = format!(
|
let mut res = format!(
|
||||||
"{}--{}--{}--{}",
|
"{}--{}--{}--{}",
|
||||||
encode_domain(&self.host, '.'),
|
Self::encode_domain(&self.host, '.'),
|
||||||
encode_domain(&self.user, '-'),
|
Self::encode_domain(&self.user, '-'),
|
||||||
encode_domain(&self.repo, '-'),
|
Self::encode_domain(&self.repo, '-'),
|
||||||
self.run,
|
self.run,
|
||||||
);
|
);
|
||||||
if let Some(artifact) = artifact {
|
if let Some(artifact) = artifact {
|
||||||
|
@ -170,15 +120,10 @@ impl<T> QueryData<T> {
|
||||||
self.host == "github.com"
|
self.host == "github.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_runquery(self) -> RunQuery {
|
pub fn siphash(&self) -> [u8; 16] {
|
||||||
RunQuery {
|
let mut h = SipHasher::new();
|
||||||
host: self.host,
|
self.hash(&mut h);
|
||||||
user: self.user,
|
h.finish128().as_bytes()
|
||||||
repo: self.repo,
|
|
||||||
run: self.run,
|
|
||||||
artifact: (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_domain(s: &str, bias: char) -> String {
|
fn encode_domain(s: &str, bias: char) -> String {
|
||||||
|
@ -246,10 +191,11 @@ fn decode_domain(s: &str, bias: char) -> String {
|
||||||
|
|
||||||
repl2.replace('\0', "-")
|
repl2.replace('\0', "-")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{ArtifactQuery, Query};
|
use super::Query;
|
||||||
|
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
@ -260,7 +206,7 @@ mod tests {
|
||||||
#[case("_h--de.x-u", '.', "-2h-1-1de-x-1u")]
|
#[case("_h--de.x-u", '.', "-2h-1-1de-x-1u")]
|
||||||
#[case("0-0", '-', "0-10")]
|
#[case("0-0", '-', "0-10")]
|
||||||
fn encode_domain(#[case] s: &str, #[case] bias: char, #[case] expect: &str) {
|
fn encode_domain(#[case] s: &str, #[case] bias: char, #[case] expect: &str) {
|
||||||
assert_eq!(super::encode_domain(s, bias), expect);
|
assert_eq!(Query::encode_domain(s, bias), expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
|
@ -269,14 +215,14 @@ mod tests {
|
||||||
#[case("-2h-1-1de-x-1u", '.', "_h--de.x-u")]
|
#[case("-2h-1-1de-x-1u", '.', "_h--de.x-u")]
|
||||||
#[case("0-10", '-', "0-0")]
|
#[case("0-10", '-', "0-0")]
|
||||||
fn decode_domain(#[case] s: &str, #[case] bias: char, #[case] expect: &str) {
|
fn decode_domain(#[case] s: &str, #[case] bias: char, #[case] expect: &str) {
|
||||||
assert_eq!(super::decode_domain(s, bias), expect);
|
assert_eq!(Query::decode_domain(s, bias), expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
proptest! {
|
proptest! {
|
||||||
#[test]
|
#[test]
|
||||||
fn pt_encode_domain_roundtrip(s in "[a-z0-9\\-_\\.]+") {
|
fn pt_encode_domain_roundtrip(s in "[a-z0-9\\-_\\.]+") {
|
||||||
let enc = super::encode_domain(&s, '-');
|
let enc = Query::encode_domain(&s, '-');
|
||||||
let dec = super::decode_domain(&enc, '-');
|
let dec = Query::decode_domain(&enc, '-');
|
||||||
assert_eq!(dec, s);
|
assert_eq!(dec, s);
|
||||||
assert!(!enc.contains("--"), "got: `{s}` -> `{enc}`");
|
assert!(!enc.contains("--"), "got: `{s}` -> `{enc}`");
|
||||||
}
|
}
|
||||||
|
@ -288,14 +234,27 @@ mod tests {
|
||||||
let query = Query::from_subdomain(d1).unwrap();
|
let query = Query::from_subdomain(d1).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
query,
|
query,
|
||||||
Query::Artifact(ArtifactQuery {
|
Query {
|
||||||
host: "github.com".to_owned(),
|
host: "github.com".to_owned(),
|
||||||
user: "thetadev".to_owned(),
|
user: "thetadev".to_owned(),
|
||||||
repo: "newpipe-extractor".to_owned(),
|
repo: "newpipe-extractor".to_owned(),
|
||||||
run: 14,
|
run: 14,
|
||||||
artifact: 123
|
artifact: Some(123),
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(query.subdomain(), d1);
|
assert_eq!(query.subdomain(), d1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn siphash() {
|
||||||
|
let q = Query {
|
||||||
|
host: "github.com".to_owned(),
|
||||||
|
user: "thetadev".to_owned(),
|
||||||
|
repo: "newpipe-extractor".to_owned(),
|
||||||
|
run: 14,
|
||||||
|
artifact: Some(123),
|
||||||
|
};
|
||||||
|
let hash = q.siphash();
|
||||||
|
assert_eq!(hex::encode(hash), "e523468ef42c848155a43f40895dff5a");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use crate::{
|
use crate::{artifact_api::Artifact, cache::ListingEntry, config::Config, query::Query};
|
||||||
artifact_api::Artifact,
|
|
||||||
cache::{ListingEntry, Size},
|
|
||||||
config::Config,
|
|
||||||
query::QueryData,
|
|
||||||
};
|
|
||||||
use yarte::{Render, Template};
|
use yarte::{Render, Template};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Version;
|
pub struct Version;
|
||||||
|
|
||||||
|
impl Render for Version {
|
||||||
|
fn render(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.write_str(env!("CARGO_PKG_VERSION"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Template, Default)]
|
#[derive(Template, Default)]
|
||||||
#[template(path = "index")]
|
#[template(path = "index")]
|
||||||
pub struct Index {
|
pub struct Index {
|
||||||
|
@ -26,11 +27,9 @@ pub struct Error<'a> {
|
||||||
#[template(path = "selection")]
|
#[template(path = "selection")]
|
||||||
pub struct Selection<'a> {
|
pub struct Selection<'a> {
|
||||||
pub main_url: &'a str,
|
pub main_url: &'a str,
|
||||||
pub version: Version,
|
|
||||||
pub run_url: &'a str,
|
pub run_url: &'a str,
|
||||||
pub run_name: &'a str,
|
pub run_name: &'a str,
|
||||||
pub publisher: LinkItem,
|
pub artifacts: Vec<LinkItem>,
|
||||||
pub artifacts: Vec<ArtifactItem>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
|
@ -38,7 +37,6 @@ pub struct Selection<'a> {
|
||||||
pub struct Listing<'a> {
|
pub struct Listing<'a> {
|
||||||
pub main_url: &'a str,
|
pub main_url: &'a str,
|
||||||
pub version: Version,
|
pub version: Version,
|
||||||
pub run_url: &'a str,
|
|
||||||
pub artifact_name: &'a str,
|
pub artifact_name: &'a str,
|
||||||
pub path_components: Vec<LinkItem>,
|
pub path_components: Vec<LinkItem>,
|
||||||
pub n_dirs: usize,
|
pub n_dirs: usize,
|
||||||
|
@ -52,38 +50,11 @@ pub struct LinkItem {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ArtifactItem {
|
impl LinkItem {
|
||||||
pub name: String,
|
pub fn from_artifact(artifact: Artifact, query: &Query, cfg: &Config) -> Self {
|
||||||
pub url: String,
|
|
||||||
pub size: Size,
|
|
||||||
pub expired: bool,
|
|
||||||
pub download_url: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ArtifactItem {
|
|
||||||
pub fn from_artifact<T>(artifact: Artifact, query: &QueryData<T>, cfg: &Config) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
name: artifact.name,
|
name: artifact.name,
|
||||||
url: cfg.url_with_subdomain(&query.subdomain_with_artifact(Some(artifact.id))),
|
url: cfg.url_with_subdomain(&query.subdomain_with_artifact(Some(artifact.id))),
|
||||||
size: Size(artifact.size as u32),
|
|
||||||
expired: artifact.expired,
|
|
||||||
download_url: artifact.user_download_url.unwrap_or(artifact.download_url),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Version {
|
|
||||||
fn render(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
f.write_str(env!("CARGO_PKG_VERSION"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Render for Size {
|
|
||||||
fn render(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"{}",
|
|
||||||
humansize::SizeFormatter::new(self.0, humansize::DECIMAL),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
47
src/util.rs
47
src/util.rs
|
@ -1,14 +1,7 @@
|
||||||
use std::{
|
use std::io::SeekFrom;
|
||||||
io::SeekFrom,
|
|
||||||
net::{IpAddr, SocketAddr},
|
|
||||||
str::FromStr,
|
|
||||||
};
|
|
||||||
|
|
||||||
use async_zip::error::ZipError;
|
use async_zip::error::ZipError;
|
||||||
use axum::{
|
use axum::{extract::Request, http::HeaderMap};
|
||||||
extract::{ConnectInfo, Request},
|
|
||||||
http::HeaderMap,
|
|
||||||
};
|
|
||||||
use headers::{Header, HeaderMapExt};
|
use headers::{Header, HeaderMapExt};
|
||||||
use http::header;
|
use http::header;
|
||||||
use mime_guess::Mime;
|
use mime_guess::Mime;
|
||||||
|
@ -143,42 +136,6 @@ pub fn get_subdomain<'a>(host: &'a str, root_domain: &str) -> Result<&'a str> {
|
||||||
Ok(stripped.trim_end_matches('.'))
|
Ok(stripped.trim_end_matches('.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_ip_address(request: &Request, real_ip_header: Option<&str>) -> Result<IpAddr> {
|
|
||||||
match real_ip_header.and_then(|header| {
|
|
||||||
request
|
|
||||||
.headers()
|
|
||||||
.get(header)
|
|
||||||
.and_then(|val| val.to_str().ok())
|
|
||||||
.and_then(|val| IpAddr::from_str(val).ok())
|
|
||||||
}) {
|
|
||||||
Some(from_header) => Ok(from_header),
|
|
||||||
None => {
|
|
||||||
let socket_addr = request
|
|
||||||
.extensions()
|
|
||||||
.get::<ConnectInfo<SocketAddr>>()
|
|
||||||
.ok_or(Error::Internal("could get request ip address".into()))?
|
|
||||||
.0;
|
|
||||||
Ok(socket_addr.ip())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait IgnoreFileNotFound {
|
|
||||||
fn ignore_file_not_found(self) -> core::result::Result<(), std::io::Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> IgnoreFileNotFound for core::result::Result<T, std::io::Error> {
|
|
||||||
fn ignore_file_not_found(self) -> core::result::Result<(), std::io::Error> {
|
|
||||||
match self {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(e) => match e.kind() {
|
|
||||||
std::io::ErrorKind::NotFound => Ok(()),
|
|
||||||
_ => todo!(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use http::{header, HeaderMap};
|
use http::{header, HeaderMap};
|
||||||
|
|
|
@ -1,46 +1,40 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<style>
|
<style>
|
||||||
* { padding: 0; margin: 0; --color-secondary: #dedede; --color-text: #000;
|
body {
|
||||||
--color-text-light: #888; --color-border: #ccc; } body { font-family: sans-serif;
|
background-color: #000;
|
||||||
text-rendering: optimizespeed; background-color: #f5f5f5; color:
|
color: #ddd;
|
||||||
var(--color-text); } a { color: #006ed3; text-decoration: none; } a:hover { color:
|
text-align: center;
|
||||||
#319cff; } .card { display: flex; flex-direction: column; width: 90%; max-width:
|
font-family: monospace;
|
||||||
500px; align-items: center; } .input-row { display: flex; width: 100%; } .center {
|
font-size: 16px;
|
||||||
width: 100%; display: flex; flex-direction: row; justify-content: center; } .light
|
width: 100%;
|
||||||
{ color: var(--color-text-light); } p { margin: 16px 0; } header { gap: 1em;
|
margin: 0;
|
||||||
padding-top: 10px; padding-bottom: 10px; background-color: #f2f2f2; } footer {
|
display: flex;
|
||||||
padding: 40px 20px; font-size: 12px; text-align: center; } @media
|
justify-content: center;
|
||||||
(prefers-color-scheme: dark) { * { --color-secondary: #082437; --color-border:
|
}
|
||||||
#212121; --color-text: #dddddd; } body { background-color: #101010; } header {
|
|
||||||
background-color: #151515; } }
|
.card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 500px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<title>Artifactview</title>
|
<title>Artifactview</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header class="center">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="50"
|
|
||||||
height="50"
|
|
||||||
viewBox="0 0 13.229 13.229"
|
|
||||||
><g aria-label="AV" style="stroke-width:.264583"><path
|
|
||||||
d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z"
|
|
||||||
style="fill:var(--color-text-light);fill-opacity:1"
|
|
||||||
/><path
|
|
||||||
d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z"
|
|
||||||
style="fill:var(--color-text);fill-opacity:1;stroke-width:.264583"
|
|
||||||
/></g></svg>
|
|
||||||
</header>
|
|
||||||
<div class="center">
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h1><span class="light">Error</span> {{status}}</h1>
|
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 13.229 13.229"><g aria-label="AV" style="font-size:10.5833px;line-height:1.25;stroke-width:.264583"><path d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z" style="fill:#888;fill-opacity:1"/><path d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z" style="font-size:10.5833px;line-height:1.25;fill:#ddd;fill-opacity:1;stroke-width:.264583"/></g></svg>
|
||||||
|
<h1><span class="dark">Error</span> {{status}}</h1>
|
||||||
<p>{{msg}}</p>
|
<p>{{msg}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,72 +1,98 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<style>
|
<style>
|
||||||
* { padding: 0; margin: 0; --color-secondary: #dedede; --color-text: #000;
|
body {
|
||||||
--color-text-light: #888; --color-border: #ccc; } body { font-family: sans-serif;
|
background-color: #000;
|
||||||
text-rendering: optimizespeed; background-color: #f5f5f5; color:
|
color: #ddd;
|
||||||
var(--color-text);} a { color: #006ed3; text-decoration: none; } a:hover { color:
|
text-align: center;
|
||||||
#319cff; } .card { display: flex; flex-direction: column; width: 90%; max-width:
|
font-family: monospace;
|
||||||
500px; align-items: center; } .input-row { display: flex; width: 100%; } .center {
|
font-size: 16px;
|
||||||
width: 100%; display: flex; flex-direction: row; justify-content: center; } .light
|
width: 100%;
|
||||||
{ color: var(--color-text-light); } input { color: inherit; font-size: 16px;
|
margin: 0;
|
||||||
height: 32px; border: 1px solid var(--color-border); padding: 4px 8px; } button {
|
display: flex;
|
||||||
background-color: #006ed3; color: #fff; padding: 4px 8px; border: none; cursor:
|
justify-content: center;
|
||||||
pointer; } button:hover { opacity: 0.7; } p { margin: 16px 0; } header { gap: 1em;
|
}
|
||||||
padding-top: 10px; padding-bottom: 10px; background-color: #f2f2f2; } footer {
|
|
||||||
padding: 40px 20px; font-size: 12px; text-align: center; } @media
|
input {
|
||||||
(prefers-color-scheme: dark) { * { --color-text: #dddddd; --color-secondary:
|
background-color: transparent;
|
||||||
#082437; --color-border: #212121; } body { background-color: #101010; } input
|
color: inherit;
|
||||||
{background-color: #151515;} header { background-color: #151515; }}
|
font-size: 16px;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 2px solid #ddd;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background-color: transparent;
|
||||||
|
color: inherit;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:active {
|
||||||
|
color: #00bfff;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:active {
|
||||||
|
color: #00bfff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 500px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-row {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<title>Artifactview</title>
|
<title>Artifactview</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="center">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="50"
|
|
||||||
height="50"
|
|
||||||
viewBox="0 0 13.229 13.229"
|
|
||||||
><g aria-label="AV" style="stroke-width:.264583"><path
|
|
||||||
d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z"
|
|
||||||
style="fill:var(--color-text-light);fill-opacity:1"
|
|
||||||
/><path
|
|
||||||
d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z"
|
|
||||||
style="fill:var(--color-text);fill-opacity:1;stroke-width:.264583"
|
|
||||||
/></g></svg>
|
|
||||||
</header>
|
|
||||||
<div class="center">
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 13.229 13.229"><g aria-label="AV" style="font-size:10.5833px;line-height:1.25;stroke-width:.264583"><path d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z" style="fill:#888;fill-opacity:1"/><path d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z" style="font-size:10.5833px;line-height:1.25;fill:#ddd;fill-opacity:1;stroke-width:.264583"/></g></svg>
|
||||||
<p>Enter a GitHub/Gitea/Forgejo Actions run url to browse CI artifacts</p>
|
<p>Enter a GitHub/Gitea/Forgejo Actions run url to browse CI artifacts</p>
|
||||||
<form method="POST" class="input-row">
|
<form method="POST" class="flex-row">
|
||||||
<input
|
<input
|
||||||
name="url"
|
name="url"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="codeberg.org/username/repo/actions/runs/42"
|
placeholder="codeberg.org/username/repo/actions/runs/42"
|
||||||
style="flex-grow: 1"
|
style="flex-grow: 1"
|
||||||
/>
|
/>
|
||||||
<button type="submit">Browse</button>
|
<button type="submit">[>]</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
<p class="footer">
|
||||||
</div>
|
Artifactview {{version}}
|
||||||
<footer>
|
|
||||||
<a
|
<a
|
||||||
href="https://code.thetadev.de/ThetaDev/artifactview"
|
href="https://code.thetadev.de/ThetaDev/artifactview"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
Artifactview
|
[Source code]
|
||||||
</a>
|
</a>
|
||||||
{{version}}
|
|
||||||
<p class="light">
|
|
||||||
<b>Disclaimer:</b>
|
|
||||||
Artifactview does not host any websites, the data is fetched from the respective
|
|
||||||
software forge and is only stored temporarily on this server. The publisher of
|
|
||||||
the artifact is the only one responsible for the content. Most forges delete
|
|
||||||
artifacts after 90 days.
|
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,129 +1,47 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
* {padding: 0;margin: 0;--color-secondary: #dedede;--color-text:
|
* {padding: 0;margin: 0;--color-secondary: #dedede;--color-text-light: gray;}body {font-family: sans-serif;text-rendering: optimizespeed;background-color: #f5f5f5;}a {color: #006ed3;text-decoration: none;}a:hover {color: #319cff;}#summary, header {padding: 0 20px;}header {display: flex;flex-direction: row;gap: 1em;padding-top: 25px;padding-bottom: 15px;background-color: #f2f2f2;}header h1 {font-size: 20px;font-weight: normal;white-space: nowrap;overflow-x: hidden;text-overflow: ellipsis;color: #999;}header h1 a {color: #000;margin: 0 4px;}footer a:hover, header h1 a:hover {text-decoration: underline;}header h1 a:first-child {margin: 0;}main {display: block;}.meta {font-size: 12px;font-family: Verdana, sans-serif;border-bottom: 1px solid #9c9c9c;padding-top: 10px;padding-bottom: 10px;}.meta-item {margin-right: 1em;}#filter {padding: 4px;border: 1px solid #ccc;}#list {width: 100%;border-collapse: collapse;}#list tr {border-bottom: 1px dashed #dadada;}#list tbody tr:hover {background-color: #ffffec;}#list td, #list th {text-align: left;padding: 10px 0;}#list th {padding-top: 15px;padding-bottom: 15px;font-size: 16px;white-space: nowrap;}#list th a {color: black;}#list th svg {vertical-align: middle;}#list td {white-space: nowrap;font-size: 14px;}#list td:nth-child(1), #list th:nth-child(1) {padding-left: 20px;width: 80%;}#list td:nth-child(2), #list th:nth-child(2) {text-align: right;padding: 0 20px;}#list td:nth-child(3), #list th:nth-child(3) {text-align: right;padding-right: 20px;}#list td:nth-child(1) svg {position: absolute;}#list td .goup, #list td .name {margin-left: 1.75em;word-break: break-all;overflow-wrap: break-word;white-space: pre-wrap;}footer {padding: 40px 20px;font-size: 12px;text-align: center;}@media (max-width: 600px) {td:nth-child(1) {width: auto;}td:nth-child(2), th:nth-child(2) {display: none;}h1 a {margin: 0;}#filter {max-width: 100px;}}@media (prefers-color-scheme: dark) {* {--color-secondary: #082437;--color-text-light: rgb(139, 157, 169);}body {background-color: #101010;color: #dddddd;}header {background-color: #151515;}#list tbody tr:hover {background-color: #252525;}#list th a, header h1 a {color: #dddddd;}a {color: #5796d1;text-decoration: none;}a:hover, h1 a:hover {color: #62b2fd;}#list tr {border-bottom: 1px dashed rgba(255, 255, 255, 0.12);}#filter {background-color: #151515;color: #ffffff;border: 1px solid #212121;}.meta {border-bottom: 1px solid #212121;}}
|
||||||
#000;--color-text-light: #888;}body {font-family: sans-serif;text-rendering:
|
|
||||||
optimizespeed;background-color: #f5f5f5;color: var(--color-text);}a {color:
|
|
||||||
#006ed3;text-decoration: none;}a:hover {color: #319cff;}#summary, header {padding:
|
|
||||||
0 20px;}header {display: flex;flex-direction: row;gap: 1em;padding-top:
|
|
||||||
25px;padding-bottom: 15px;background-color: #f2f2f2;}header h1 {font-size:
|
|
||||||
20px;font-weight: normal;white-space: nowrap;overflow-x: hidden;text-overflow:
|
|
||||||
ellipsis;color: #999;}header h1 a {color: var(--color-text);margin: 0 4px;}footer
|
|
||||||
a:hover, header h1 a:hover {text-decoration: underline;}header h1 a:first-child
|
|
||||||
{margin: 0;}main {display: block;}.meta {font-size: 12px;font-family: Verdana,
|
|
||||||
sans-serif;border-bottom: 1px solid #9c9c9c;padding-top: 10px;padding-bottom:
|
|
||||||
10px;}.meta-item {margin-right: 1em;}#filter {padding: 4px;border: 1px solid
|
|
||||||
#ccc;}#list {width: 100%;border-collapse: collapse;}#list tr {border-bottom: 1px
|
|
||||||
dashed #dadada;}#list tbody tr:hover {background-color: #ffffec;}#list td, #list
|
|
||||||
th {text-align: left;padding: 10px 0;}#list th {padding-top: 15px;padding-bottom:
|
|
||||||
15px;font-size: 16px;white-space: nowrap;}#list th a {color:
|
|
||||||
var(--color-text);}#list th svg {vertical-align: middle;}#list td {white-space:
|
|
||||||
nowrap;font-size: 14px;}#list td:nth-child(1), #list th:nth-child(1)
|
|
||||||
{padding-left: 20px;width: 80%;}#list td:nth-child(2), #list th:nth-child(2)
|
|
||||||
{text-align: right;padding: 0 20px;}#list td:nth-child(3), #list th:nth-child(3)
|
|
||||||
{text-align: right;padding-right: 20px;}#list td:nth-child(1) svg {position:
|
|
||||||
absolute;}#list td .goup, #list td .name {margin-left: 1.75em;word-break:
|
|
||||||
break-all;overflow-wrap: break-word;white-space: pre-wrap;}footer {padding: 40px
|
|
||||||
20px;font-size: 12px;text-align: center;}@media (max-width: 600px)
|
|
||||||
{td:nth-child(1) {width: auto;}td:nth-child(2), th:nth-child(2) {display: none;}h1
|
|
||||||
a {margin: 0;}#filter {max-width: 100px;}}@media (prefers-color-scheme: dark) {*
|
|
||||||
{--color-secondary: #082437;--color-text: #dddddd;}
|
|
||||||
body {background-color: #101010;}header {background-color:
|
|
||||||
#151515;}#list tbody tr:hover {background-color: #252525;}a {color:
|
|
||||||
#5796d1;text-decoration: none;}a:hover, h1 a:hover {color: #62b2fd;}#list tr
|
|
||||||
{border-bottom: 1px dashed rgba(255, 255, 255, 0.12);}#filter {background-color:
|
|
||||||
#151515;color: #ffffff;border: 1px solid #212121;}.meta {border-bottom: 1px solid
|
|
||||||
#212121;}}
|
|
||||||
</style>
|
</style>
|
||||||
<title>
|
<title>
|
||||||
Index:
|
Index of {{artifact_name}}
|
||||||
{{artifact_name}}
|
|
||||||
</title>
|
</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="initFilter()">
|
<body onload="initFilter()">
|
||||||
<svg
|
<svg xmlns="http://www.w3.org/2000/svg" height="0" width="0" style="position:absolute"><defs><g id="folder" fill-rule="nonzero" fill="none"><path d="M285.22 37.55h-142.6L110.9 0H31.7C14.25 0 0 16.9 0 37.55v75.1h316.92V75.1c0-20.65-14.26-37.55-31.7-37.55z" fill="#FFA000"/><path d="M285.22 36H31.7C14.25 36 0 50.28 0 67.74v158.7c0 17.47 14.26 31.75 31.7 31.75h253.5c17.44 0 31.7-14.3 31.7-31.75V67.75c0-17.47-14.26-31.75-31.7-31.75z" fill="#FFCA28"/></g><g id="file" stroke="#000" stroke-width="25" fill="#FFF" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><path d="M13 24.12v274.76c0 6.16 5.87 11.12 13.17 11.12H239c7.3 0 13.17-4.96 13.17-11.12V136.15S132.6 13 128.37 13H26.17C18.87 13 13 17.96 13 24.12z"/><path d="M129.37 13 129 113.9c0 10.58 7.26 19.1 16.27 19.1H249L129.37 13z"/></g></defs></svg>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
height="0"
|
|
||||||
width="0"
|
|
||||||
style="position:absolute"
|
|
||||||
><defs><g id="folder" fill-rule="nonzero" fill="none"><path
|
|
||||||
d="M285.22 37.55h-142.6L110.9 0H31.7C14.25 0 0 16.9 0 37.55v75.1h316.92V75.1c0-20.65-14.26-37.55-31.7-37.55z"
|
|
||||||
fill="#FFA000"
|
|
||||||
/><path
|
|
||||||
d="M285.22 36H31.7C14.25 36 0 50.28 0 67.74v158.7c0 17.47 14.26 31.75 31.7 31.75h253.5c17.44 0 31.7-14.3 31.7-31.75V67.75c0-17.47-14.26-31.75-31.7-31.75z"
|
|
||||||
fill="#FFCA28"
|
|
||||||
/></g><g
|
|
||||||
id="file"
|
|
||||||
stroke="#000"
|
|
||||||
stroke-width="25"
|
|
||||||
fill="#FFF"
|
|
||||||
fill-rule="evenodd"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
><path
|
|
||||||
d="M13 24.12v274.76c0 6.16 5.87 11.12 13.17 11.12H239c7.3 0 13.17-4.96 13.17-11.12V136.15S132.6 13 128.37 13H26.17C18.87 13 13 17.96 13 24.12z"
|
|
||||||
/><path
|
|
||||||
d="M129.37 13 129 113.9c0 10.58 7.26 19.1 16.27 19.1H249L129.37 13z"
|
|
||||||
/></g></defs></svg>
|
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<a href="{{main_url}}" aria-label="Back to main page" style="height: 32px;">
|
<a href="{{main_url}}" aria-label="Back to main page" style="height: 32px;">
|
||||||
<svg
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 13.229 13.229"><g aria-label="AV" style="font-size:10.5833px;line-height:1.25;stroke-width:.264583"><path d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z" style="fill:#888;fill-opacity:1"/><path d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z" style="font-size:10.5833px;line-height:1.25;fill:#ddd;fill-opacity:1;stroke-width:.264583"/></g></svg>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
viewBox="0 0 13.229 13.229"
|
|
||||||
><g
|
|
||||||
aria-label="AV"
|
|
||||||
style="stroke-width:.264583"
|
|
||||||
><path
|
|
||||||
d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z"
|
|
||||||
style="fill:var(--color-text-light);fill-opacity:1"
|
|
||||||
/><path
|
|
||||||
d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z"
|
|
||||||
style="fill:var(--color-text);fill-opacity:1;stroke-width:.264583"
|
|
||||||
/></g></svg>
|
|
||||||
</a>
|
</a>
|
||||||
<h1>
|
<h1>
|
||||||
{{#each path_components}}<a href="{{this.url}}">{{this.name}}</a> /{{/each}}
|
{{#each path_components}}<a href="{{this.url}}">{{this.name}}</a> /{{/each}}
|
||||||
</h1>
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<div id="summary">
|
<div id="summary">
|
||||||
<span class="meta-item"><b>{{n_dirs}}</b> director{{#if n_dirs != 1}}ies{{else}}y{{/if}}</span>
|
<span class="meta-item"><b>{{n_dirs}}</b> directories</span>
|
||||||
<span class="meta-item"><b>{{n_files}}</b> file{{#if n_files != 1}}s{{/if}}</span>
|
<span class="meta-item"><b>{{n_files}}</b> files</span>
|
||||||
<span class="meta-item"><a
|
<span class="meta-item"><input type="text" placeholder="filter" id="filter" onkeyup="filter()"/></span>
|
||||||
href="{{run_url}}"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>CI run</a></span>
|
|
||||||
<span class="meta-item"><input
|
|
||||||
type="text"
|
|
||||||
placeholder="filter"
|
|
||||||
id="filter"
|
|
||||||
onkeyup="filter()"
|
|
||||||
/></span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="listing">
|
<div class="listing">
|
||||||
<table id="list" aria-describedby="summary">
|
<table id="list" aria-describedby="summary">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><a href="?C=N&O=A">Name</a> <a
|
<th><a href="?C=N&O=A">Name</a> <a href="?C=N&O=D"> ↓ </a></th>
|
||||||
href="?C=N&O=D"
|
<th><a href="?C=S&O=A">Size</a> <a href="?C=S&O=D"> ↓ </a></th>
|
||||||
> ↓ </a></th>
|
|
||||||
<th><a href="?C=S&O=A">Size</a> <a
|
|
||||||
href="?C=S&O=D"
|
|
||||||
> ↓ </a></th>
|
|
||||||
<th>CRC32</th>
|
<th>CRC32</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
|
||||||
{{#if has_parent}}
|
{{#if has_parent}}
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=".."><span class="goup">Parent directory</span></a></td>
|
<td><a href=".."><span class="goup">Parent directory</span></a></td>
|
||||||
<td>—</td>
|
<td>—</td>
|
||||||
|
@ -148,25 +66,15 @@
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Served with
|
Served with <a href="https://code.thetadev.de/ThetaDev/artifactview" target="_blank" rel="noopener noreferrer">Artifactview</a> {{version}}
|
||||||
<a
|
|
||||||
href="https://code.thetadev.de/ThetaDev/artifactview"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>Artifactview</a>
|
|
||||||
{{version}}
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// @license
|
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT
|
||||||
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT var
|
|
||||||
filterEl=document.getElementById("filter");function
|
var filterEl=document.getElementById("filter");function initFilter(){if(!filterEl.value){var filterParam=new URL(window.location.href).searchParams.get("filter");if(filterParam){filterEl.value=filterParam}}filter()}function filter(){var q=filterEl.value.trim().toLowerCase();var elems=document.querySelectorAll("tr.file");elems.forEach(function(el){if(!q){el.style.display="";return}var nameEl=el.querySelector("td");var nameVal=nameEl.textContent.trim().toLowerCase();if(nameVal.indexOf(q)!==-1){el.style.display=""}else{el.style.display="none"}})}
|
||||||
initFilter(){if(!filterEl.value){var filterParam=new
|
|
||||||
URL(window.location.href).searchParams.get("filter");if(filterParam){filterEl.value=filterParam}}filter()}function
|
|
||||||
filter(){var q=filterEl.value.trim().toLowerCase();var
|
|
||||||
elems=document.querySelectorAll("tr.file");elems.forEach(function(el){if(!q){el.style.display="";return}var
|
|
||||||
nameEl=el.querySelector("td");var
|
|
||||||
nameVal=nameEl.textContent.trim().toLowerCase();if(nameVal.indexOf(q)!==-1){el.style.display=""}else{el.style.display="none"}})}
|
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,186 +1,49 @@
|
||||||
<html>
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<style type="text/css">
|
<style>
|
||||||
* {padding: 0;margin: 0;--color-secondary: #dedede;--color-text:
|
body {
|
||||||
#000;--color-text-light: #888;}body {font-family: sans-serif;text-rendering:
|
background-color: #000;
|
||||||
optimizespeed;background-color: #f5f5f5;color: var(--color-text);}a {color:
|
color: #ddd;
|
||||||
#006ed3;text-decoration: none;}a:hover {color: #319cff;}#summary, header {padding:
|
text-align: center;
|
||||||
0 20px;}header {display: flex;flex-direction: row;gap: 1em;padding-top:
|
font-family: monospace;
|
||||||
25px;padding-bottom: 15px;background-color: #f2f2f2;}header h1 {font-size:
|
font-size: 16px;
|
||||||
20px;font-weight: normal;white-space: nowrap;overflow-x: hidden;text-overflow:
|
width: 100%;
|
||||||
ellipsis;color: #999;}header h1 a {color: var(--color-text);margin: 0 4px;}footer
|
margin: 0;
|
||||||
a:hover, header h1 a:hover {text-decoration: underline;}header h1 a:first-child
|
display: flex;
|
||||||
{margin: 0;}main {display: block;}.meta {font-size: 12px;font-family: Verdana,
|
justify-content: center;
|
||||||
sans-serif;border-bottom: 1px solid #9c9c9c;padding-top: 10px;padding-bottom:
|
}
|
||||||
10px;}.meta-item {margin-right: 1em;}#filter {padding: 4px;border: 1px solid
|
|
||||||
#ccc;}#list {width: 100%;border-collapse: collapse;}#list tr {border-bottom: 1px
|
a {
|
||||||
dashed #dadada;}#list tbody tr:hover {background-color: #ffffec;}#list td, #list
|
color: inherit;
|
||||||
th {text-align: left;padding: 10px 0;}#list th {padding-top: 15px;padding-bottom:
|
text-decoration: underline;
|
||||||
15px;font-size: 16px;white-space: nowrap;}#list th a {color:
|
}
|
||||||
var(--color-text);}#list th svg {vertical-align: middle;}#list td {white-space:
|
|
||||||
nowrap;font-size: 14px;}#list td:nth-child(1), #list th:nth-child(1)
|
a:active {
|
||||||
{padding-left: 20px;width: 80%;}#list td:nth-child(2), #list th:nth-child(2)
|
color: #00bfff;
|
||||||
{text-align: right;padding: 0 20px;}#list td:nth-child(3), #list th:nth-child(3)
|
}
|
||||||
{text-align: right;padding-right: 20px;}#list td:nth-child(1) svg {position:
|
|
||||||
absolute;}#list td .goup, #list td .name {margin-left: 1.75em;word-break:
|
.card {
|
||||||
break-all;overflow-wrap: break-word;white-space: pre-wrap;}footer {padding: 40px
|
display: flex;
|
||||||
20px;font-size: 12px;text-align: center;}p { margin: 16px 0; }.light{ color:
|
flex-direction: column;
|
||||||
var(--color-text-light); } @media (max-width: 600px)
|
width: 90%;
|
||||||
{td:nth-child(1) {width: auto;}td:nth-child(2), th:nth-child(2) {display: none;}h1
|
max-width: 500px;
|
||||||
a {margin: 0;}#filter {max-width: 100px;}}.expired {filter: grayscale(100%);}
|
align-items: center;
|
||||||
@media (prefers-color-scheme: dark) {*{--color-secondary: #082437;--color-text: #dddddd;}
|
}
|
||||||
body {background-color: #101010;}header {background-color:
|
|
||||||
#151515;}#list tbody tr:hover {background-color: #252525;}a {color:
|
|
||||||
#5796d1;text-decoration: none;}a:hover, h1 a:hover {color: #62b2fd;}#list tr
|
|
||||||
{border-bottom: 1px dashed rgba(255, 255, 255, 0.12);}#filter {background-color:
|
|
||||||
#151515;color: #ffffff;border: 1px solid #212121;}.meta {border-bottom: 1px solid
|
|
||||||
#212121;}}
|
|
||||||
</style>
|
</style>
|
||||||
<title>
|
<title>Artifactview</title>
|
||||||
Artifacts:
|
|
||||||
{{run_name}}
|
|
||||||
</title>
|
|
||||||
</head>
|
</head>
|
||||||
|
<body>
|
||||||
<body onload="initFilter()">
|
<div class="card">
|
||||||
<svg
|
<a href="{{main_url}}" aria-label="Back to main page" style="height: 50px;">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 13.229 13.229"><g aria-label="AV" style="font-size:10.5833px;line-height:1.25;stroke-width:.264583"><path d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z" style="fill:#888;fill-opacity:1"/><path d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z" style="font-size:10.5833px;line-height:1.25;fill:#ddd;fill-opacity:1;stroke-width:.264583"/></g></svg>
|
||||||
height="0"
|
|
||||||
width="0"
|
|
||||||
style="position:absolute"
|
|
||||||
><defs><g id="folder" fill-rule="nonzero" fill="none"><path
|
|
||||||
d="M285.22 37.55h-142.6L110.9 0H31.7C14.25 0 0 16.9 0 37.55v75.1h316.92V75.1c0-20.65-14.26-37.55-31.7-37.55z"
|
|
||||||
fill="#FFA000"
|
|
||||||
/><path
|
|
||||||
d="M285.22 36H31.7C14.25 36 0 50.28 0 67.74v158.7c0 17.47 14.26 31.75 31.7 31.75h253.5c17.44 0 31.7-14.3 31.7-31.75V67.75c0-17.47-14.26-31.75-31.7-31.75z"
|
|
||||||
fill="#FFCA28"
|
|
||||||
/></g></defs></svg>
|
|
||||||
|
|
||||||
<header>
|
|
||||||
<a href="{{main_url}}" aria-label="Back to main page" style="height: 32px;">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
viewBox="0 0 13.229 13.229"
|
|
||||||
><g
|
|
||||||
aria-label="AV"
|
|
||||||
style="stroke-width:.264583"
|
|
||||||
><path
|
|
||||||
d="m12.381 2.878-2.698 7.557H8.73L6.031 2.878h.995L8.73 7.725q.17.466.286.879.116.402.19.772.074-.37.19-.783.117-.413.287-.889l1.693-4.826Z"
|
|
||||||
style="fill:#888;fill-opacity:1"
|
|
||||||
/><path
|
|
||||||
d="m1.158 10.435 2.699-7.557h.952l2.699 7.557h-.995L4.81 5.588q-.169-.466-.285-.879-.117-.402-.19-.772-.075.37-.191.783-.117.412-.286.889l-1.694 4.826Z"
|
|
||||||
style="fill:#ddd;fill-opacity:1;stroke-width:.264583"
|
|
||||||
/></g></svg>
|
|
||||||
</a>
|
</a>
|
||||||
<h1>
|
<p>CI artifacts for <a href="{{run_url}}" target="_blank" rel="noopener noreferrer">{{run_name}}</a>:</p>
|
||||||
<a href="/">{{run_name}}</a>
|
|
||||||
/
|
|
||||||
</h1>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<div class="meta">
|
|
||||||
<div id="summary">
|
|
||||||
<span class="meta-item"><b>{{artifacts.len()}}</b> artifact{{#if artifacts.len() != 1}}s{{/if}}</span>
|
|
||||||
<span class="meta-item"><a
|
|
||||||
href="{{run_url}}"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>CI run</a></span>
|
|
||||||
<span class="meta-item"><input
|
|
||||||
type="text"
|
|
||||||
placeholder="filter"
|
|
||||||
id="filter"
|
|
||||||
onkeyup="filter()"
|
|
||||||
/></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="listing">
|
|
||||||
<table id="list" aria-describedby="summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Artifact</th>
|
|
||||||
<th>Size</th>
|
|
||||||
<th>Download</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{#each artifacts}}
|
{{#each artifacts}}
|
||||||
<tr class="file">
|
<a href="{{this.url}}">{{this.name}}</a>
|
||||||
{{#if this.expired}}
|
|
||||||
<td>
|
|
||||||
<svg
|
|
||||||
class="expired"
|
|
||||||
width="1.5em"
|
|
||||||
height="1em"
|
|
||||||
version="1.1"
|
|
||||||
viewBox="0 0 317 259"
|
|
||||||
><use xlink:href="#folder"></use></svg>
|
|
||||||
<span class="name light">{{this.name}}</span>
|
|
||||||
</td>
|
|
||||||
{{else}}
|
|
||||||
<td>
|
|
||||||
<a href="{{this.url}}">
|
|
||||||
<svg
|
|
||||||
width="1.5em"
|
|
||||||
height="1em"
|
|
||||||
version="1.1"
|
|
||||||
viewBox="0 0 317 259"
|
|
||||||
><use xlink:href="#folder"></use></svg>
|
|
||||||
<span class="name">{{this.name}}</span>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
{{/if}}
|
|
||||||
<td>{{this.size}}</td>
|
|
||||||
<td>
|
|
||||||
{{#if this.expired}}
|
|
||||||
—
|
|
||||||
{{else}}
|
|
||||||
<a href="{{this.download_url}}" rel="noopener noreferrer">Download</a>
|
|
||||||
{{/if}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
Served with
|
|
||||||
<a
|
|
||||||
href="https://code.thetadev.de/ThetaDev/artifactview"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>Artifactview</a>
|
|
||||||
{{version}}
|
|
||||||
<p class="light">
|
|
||||||
<b>Disclaimer:</b> Artifactview does not host any websites, the data is fetched
|
|
||||||
from the respective software forge and is only stored temporarily on this server.
|
|
||||||
The publisher of this artifact,
|
|
||||||
<a href="{{publisher.url}}" target="_blank" rel="noopener noreferrer">{{publisher.name}}</a>,
|
|
||||||
is the only one responsible for the content.
|
|
||||||
Most forges delete artifacts after 90 days.
|
|
||||||
</p>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
// @license
|
|
||||||
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT var
|
|
||||||
filterEl=document.getElementById("filter");function
|
|
||||||
initFilter(){if(!filterEl.value){var filterParam=new
|
|
||||||
URL(window.location.href).searchParams.get("filter");if(filterParam){filterEl.value=filterParam}}filter()}function
|
|
||||||
filter(){var q=filterEl.value.trim().toLowerCase();var
|
|
||||||
elems=document.querySelectorAll("tr.file");elems.forEach(function(el){if(!q){el.style.display="";return}var
|
|
||||||
nameEl=el.querySelector("td");var
|
|
||||||
nameVal=nameEl.textContent.trim().toLowerCase();if(nameVal.indexOf(q)!==-1){el.style.display=""}else{el.style.display="none"}})}
|
|
||||||
// @license-end
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue