From 87395baa9b05057637a14d28a7d77814ecf08adc Mon Sep 17 00:00:00 2001 From: James Date: Sat, 28 Jul 2018 15:33:06 +1000 Subject: [PATCH] Clean up dependencies --- Cargo.lock | 77 +++++++++++++++++++++++----------- Cargo.toml | 9 ++-- src/assets.rs | 2 + src/main.rs | 12 +++--- src/sources/github/mod.rs | 87 +++++++++++---------------------------- static/index.html | 5 ++- 6 files changed, 93 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 167c720..c82ab83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,6 +107,14 @@ name = "dtoa" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "encoding_rs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "flate2" version = "1.0.1" @@ -174,7 +182,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hyper" -version = "0.11.15" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -182,9 +190,11 @@ dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -193,6 +203,7 @@ dependencies = [ "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "want 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -201,7 +212,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.15 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -282,23 +293,21 @@ name = "liftinstall" version = "0.1.0" dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.15 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "mime_guess 1.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)", + "mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)", "phf_macros 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "web-view 0.1.3 (git+https://github.com/Boscop/web-view.git?rev=3932662)", + "web-view 0.2.1 (git+https://github.com/Boscop/web-view.git?rev=555f422d09cbb94e82a728d47e9e07ca91963f6e)", "zip 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -349,7 +358,7 @@ dependencies = [ [[package]] name = "mime_guess" -version = "1.8.3" +version = "1.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -621,12 +630,13 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.15 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -639,7 +649,7 @@ dependencies = [ "tokio-io 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -880,6 +890,11 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "try-lock" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicase" version = "1.4.2" @@ -944,10 +959,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uuid" -version = "0.5.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -965,20 +981,30 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "want" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "web-view" -version = "0.1.3" -source = "git+https://github.com/Boscop/web-view.git?rev=3932662#39326627100c0884bc1ca3fa8cae612ea9a45c14" +version = "0.2.1" +source = "git+https://github.com/Boscop/web-view.git?rev=555f422d09cbb94e82a728d47e9e07ca91963f6e#555f422d09cbb94e82a728d47e9e07ca91963f6e" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "urlencoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webview-sys 0.1.0 (git+https://github.com/Boscop/web-view.git?rev=3932662)", + "webview-sys 0.1.0 (git+https://github.com/Boscop/web-view.git?rev=555f422d09cbb94e82a728d47e9e07ca91963f6e)", ] [[package]] name = "webview-sys" version = "0.1.0" -source = "git+https://github.com/Boscop/web-view.git?rev=3932662#39326627100c0884bc1ca3fa8cae612ea9a45c14" +source = "git+https://github.com/Boscop/web-view.git?rev=555f422d09cbb94e82a728d47e9e07ca91963f6e#555f422d09cbb94e82a728d47e9e07ca91963f6e" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1052,6 +1078,7 @@ dependencies = [ "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" "checksum crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5d02c0aac6bd68393ed69e00bbc2457f3e89075c6349db7189618dc4ddc1d7" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum encoding_rs 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98fd0f24d1fb71a4a6b9330c8ca04cbd4e7cc5d846b54ca74ff376bc7c9f798d" "checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" @@ -1062,7 +1089,7 @@ dependencies = [ "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37" -"checksum hyper 0.11.15 (registry+https://github.com/rust-lang/crates.io-index)" = "4d6105c5eeb03068b10ff34475a0d166964f98e7b9777cc34b342a225af9b87c" +"checksum hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)" = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7" "checksum hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c81fa95203e2a6087242c38691a0210f23e9f3f8f944350bd676522132e2985" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" @@ -1080,7 +1107,7 @@ dependencies = [ "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd" -"checksum mime_guess 1.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dc7e82a15629bb4ecd9e72365bf33d1382be91e030f820edb8e2a21c02430da8" +"checksum mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4c0961143b8efdcfa29c3ae63281601b446a4a668165454b6c90f8024954c5" "checksum mime_guess 2.0.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "013572795763289e14710c7b279461295f2673b2b338200c235082cd7ca9e495" "checksum miniz_oxide 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aaa2d3ad070f428fffbd7d3ca2ea20bb0d8cffe9024405c44e1840bc1418b398" "checksum miniz_oxide_c_api 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92d98fdbd6145645828069b37ea92ca3de225e000d80702da25c20d3584b38a5" @@ -1110,7 +1137,7 @@ dependencies = [ "checksum regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "744554e01ccbd98fff8c457c3b092cd67af62a555a43bfe97ae8a0451f7799fa" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum relay 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f301bafeb60867c85170031bdb2fcf24c8041f33aee09e7b116a58d4e9f781c5" -"checksum reqwest 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "449c45f593ce9af9417c91e22f274fb8cea013bcf3d37ec1b5fb534b623bc708" +"checksum reqwest 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2abe46f8e00792693a2488e296c593d1f4ea39bb1178cfce081d6793657575e4" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "acece75e0f987c48863a6c792ec8b7d6c4177d4a027f8ccc72f849794f437016" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" @@ -1139,6 +1166,7 @@ dependencies = [ "checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" "checksum tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772f4b04e560117fe3b0a53e490c16ddc8ba6ec437015d91fa385564996ed913" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" +"checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" @@ -1148,12 +1176,13 @@ dependencies = [ "checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2" "checksum urlencoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3df3561629a8bb4c57e5a2e4c43348d9e29c7c29d9b1c4c1f47166deca8f37ed" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22" +"checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum web-view 0.1.3 (git+https://github.com/Boscop/web-view.git?rev=3932662)" = "" -"checksum webview-sys 0.1.0 (git+https://github.com/Boscop/web-view.git?rev=3932662)" = "" +"checksum want 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" +"checksum web-view 0.2.1 (git+https://github.com/Boscop/web-view.git?rev=555f422d09cbb94e82a728d47e9e07ca91963f6e)" = "" +"checksum webview-sys 0.1.0 (git+https://github.com/Boscop/web-view.git?rev=555f422d09cbb94e82a728d47e9e07ca91963f6e)" = "" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index b280d6b..45c5d95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,16 +7,14 @@ documentation = "https://liftinstall.jselby.net" description = "An adaptable installer for your application." [dependencies] -web-view = {git = "https://github.com/Boscop/web-view.git", rev = "3932662"} +web-view = {git = "https://github.com/Boscop/web-view.git", rev = "555f422d09cbb94e82a728d47e9e07ca91963f6e"} -hyper = "0.11.15" -hyper-tls = "0.1.2" -tokio-core = "*" +hyper = "0.11.27" futures = "*" mime_guess = "1.8.3" url = "*" -reqwest = "0.8.4" +reqwest = "0.8.6" number_prefix = "0.2.7" phf = "0.7.22" @@ -28,6 +26,7 @@ serde_json = "1.0.9" toml = "0.4" +# TODO: Use web-view for this one nfd = "0.0.4" semver = {version = "0.9.0", features = ["serde"]} diff --git a/src/assets.rs b/src/assets.rs index 75155ae..3aa6946 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -3,6 +3,8 @@ extern crate mime_guess; use assets::mime_guess::{get_mime_type, octet_stream}; +use phf; + macro_rules! include_files_as_assets { ( $field_name:ident, $( $file_name:expr ),* ) => { static $field_name: phf::Map<&'static str, &'static [u8]> = phf_map!( diff --git a/src/main.rs b/src/main.rs index bc82b3d..c95ae4b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,11 @@ #![windows_subsystem = "windows"] -#![feature(extern_prelude)] #![feature(plugin)] #![plugin(phf_macros)] extern crate web_view; -extern crate futures; extern crate hyper; -extern crate hyper_tls; -extern crate tokio_core; +extern crate futures; extern crate number_prefix; extern crate reqwest; @@ -79,7 +76,12 @@ fn main() { resizable, debug, |_| {}, - |_, _, _| {}, + |wv, msg, _| { + println!("Incoming payload: {:?}", msg); + if msg == "select-install-dir" { + wv.dialog(Dialog::ChooseDirectory, "Select a install directory...", ""); + } + }, (), ); } diff --git a/src/sources/github/mod.rs b/src/sources/github/mod.rs index 16435d1..ec6853f 100644 --- a/src/sources/github/mod.rs +++ b/src/sources/github/mod.rs @@ -1,17 +1,7 @@ /// github/mod.rs -use futures::{Future, Stream}; - -use tokio_core::reactor::Core; - -use hyper::header::UserAgent; -use hyper::Client; -use hyper::Method; -use hyper::Request; -use hyper::Uri; - -use hyper_tls::HttpsConnector; - -use toml; +use reqwest; +use reqwest::header::UserAgent; +use reqwest::StatusCode; use serde_json; @@ -34,63 +24,34 @@ impl GithubReleases { impl ReleaseSource for GithubReleases { fn get_current_releases(&self, config: &TomlValue) -> Result, String> { // Reparse our Config as strongly typed - let config_string = match toml::to_string(config) { + let config : GithubConfig = match config.clone().try_into() { Ok(v) => v, - Err(v) => return Err(format!("Failed to convert config: {:?}", v)), + Err(v) => return Err(format!("Failed to parse release config: {:?}", v)), }; - let config: GithubConfig = match toml::from_str(&config_string) { - Ok(v) => v, - Err(v) => return Err(format!("Failed to convert config: {:?}", v)), - }; - - let mut core = match Core::new() { - Ok(v) => v, - Err(v) => return Err(format!("Failed to init Tokio: {:?}", v)), - }; - - // Build the HTTP client up - let client = Client::configure() - .connector(match HttpsConnector::new(4, &core.handle()) { - Ok(v) => v, - Err(v) => return Err(format!("Failed to init https: {:?}", v)), - }) - .build(&core.handle()); - let mut results: Vec = Vec::new(); - let target_url: Uri = - match format!("https://api.github.com/repos/{}/releases", config.repo).parse() { - Ok(v) => v, - Err(v) => return Err(format!("Failed to generate target url: {:?}", v)), - }; - let mut req = Request::new(Method::Get, target_url); - req.headers_mut() - .set(UserAgent::new("installer-rs (j-selby)")); + // Build the HTTP client up + let client = reqwest::Client::new(); + let mut response = client.get(&format!("https://api.github.com/repos/{}/releases", config.repo)) + .header(UserAgent::new("liftinstall (j-selby)")) + .send() + .map_err(|x| format!("Error while sending HTTP request: {:?}", x))?; - // Build our future - let future = client.request(req).and_then(|res| { - res.body().concat2().and_then(move |body| { - let raw_json: Result = - match serde_json::from_slice(&body) { - Ok(v) => Ok(v), - Err(v) => Err(format!("Failed to parse response: {:?}", v)), - }; + if response.status() != StatusCode::Ok { + return Err(format!("Bad status code: {:?}", response.status())); + } - Ok(raw_json) - }) - }); + let body = response.text() + .map_err(|x| format!("Failed to decode HTTP response body: {:?}", x))?; - // Unwrap the future's results - let result: serde_json::Value = match core.run(future) { - Ok(v) => v, - Err(v) => return Err(format!("Failed to fetch info: {:?}", v)), - }?; + let result: serde_json::Value = serde_json::from_str(&body) + .map_err(|x| format!("Failed to parse response: {:?}", x))?; - let result: &Vec = match result.as_array() { - Some(v) => v, - None => return Err(format!("JSON payload not an array")), - }; + let result: &Vec = + result + .as_array() + .ok_or(format!("Response was not an array!"))?; // Parse JSON from server for entry in result.into_iter() { @@ -126,8 +87,8 @@ impl ReleaseSource for GithubReleases { }; files.push(File { - name: string.to_owned(), - url: url.to_owned(), + name: string.to_string(), + url: url.to_string(), }); } diff --git a/static/index.html b/static/index.html index 304ddad..dd8da6f 100644 --- a/static/index.html +++ b/static/index.html @@ -165,11 +165,12 @@ }, methods: { "select_file": function() { - ajax("/api/file-select", function(e) { + window.external.invoke("select-install-dir"); + /*ajax("/api/file-select", function(e) { if (e.path != null) { app.install_location = e.path; } - }); + });*/ }, "install": function() { this.select_packages = false;