From bd4c524f281120628b3715fd12d3b862de4c58d3 Mon Sep 17 00:00:00 2001 From: ddotthomas Date: Sat, 24 Feb 2024 21:38:57 -0700 Subject: [PATCH] Fixed a couple things and added some comments and documentation --- Cargo.lock | 438 +++++++++++++++----------------- libprotonup/src/apps.rs | 13 +- libprotonup/src/files.rs | 36 ++- libprotonup/src/github.rs | 8 + libprotonup/src/variants.rs | 13 +- protonup-rs/src/download.rs | 14 +- protonup-rs/src/file_path.rs | 3 +- protonup-rs/src/helper_menus.rs | 7 +- protonup-rs/src/main.rs | 12 +- protonup-rs/src/manage_apps.rs | 6 +- 10 files changed, 271 insertions(+), 279 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9d59b3..65f3129 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ "anstyle", "anstyle-parse", @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "atty" @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" @@ -126,9 +126,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "bytes" @@ -153,12 +153,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "3286b845d0fccbdd15af433f61c5970e711987036cb468f437ff6badd70f4e24" [[package]] name = "cfg-if" @@ -183,9 +180,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", "clap_derive", @@ -193,33 +190,33 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.10.0", + "strsim 0.11.0", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" @@ -229,15 +226,15 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -258,18 +255,18 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -342,6 +339,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "filetime" version = "0.2.23" @@ -381,53 +388,53 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", @@ -452,9 +459,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -469,9 +476,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -518,9 +525,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" [[package]] name = "hex" @@ -570,9 +577,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -585,7 +592,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2", "tokio", "tower-service", "tracing", @@ -618,9 +625,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown", @@ -628,9 +635,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" dependencies = [ "console", "instant", @@ -679,9 +686,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -694,9 +701,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libprotonup" @@ -724,11 +731,17 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall 0.4.1", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "log" version = "0.4.20" @@ -748,9 +761,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mime" @@ -760,9 +773,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -793,7 +806,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.8", "libc", ] @@ -811,9 +824,9 @@ checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -850,9 +863,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "portable-atomic" @@ -886,9 +899,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -897,7 +910,7 @@ dependencies = [ name = "protonup-rs" version = "0.6.0" dependencies = [ - "clap 4.4.11", + "clap 4.5.1", "indicatif", "inquire", "libprotonup", @@ -906,9 +919,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -950,9 +963,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "base64", "bytes", @@ -976,6 +989,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-rustls", @@ -992,16 +1006,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin", "untrusted", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1010,6 +1025,19 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" version = "0.21.10" @@ -1043,9 +1071,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "sct" @@ -1059,29 +1087,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -1122,22 +1150,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1154,9 +1172,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "structopt" @@ -1195,15 +1213,21 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "system-configuration" version = "0.5.1" @@ -1259,22 +1283,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", ] [[package]] @@ -1294,9 +1318,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -1304,7 +1328,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -1317,7 +1341,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", ] [[package]] @@ -1383,9 +1407,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -1395,18 +1419,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -1466,9 +1490,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1476,24 +1500,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -1503,9 +1527,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1513,28 +1537,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.50", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-streams" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", @@ -1545,9 +1569,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -1555,9 +1579,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "winapi" @@ -1581,15 +1605,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -1605,22 +1620,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.52.3", ] [[package]] @@ -1640,25 +1640,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -1667,15 +1661,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" [[package]] name = "windows_aarch64_msvc" @@ -1685,15 +1673,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" [[package]] name = "windows_i686_gnu" @@ -1703,15 +1685,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" [[package]] name = "windows_i686_msvc" @@ -1721,15 +1697,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" [[package]] name = "windows_x86_64_gnu" @@ -1739,15 +1709,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" [[package]] name = "windows_x86_64_gnullvm" @@ -1757,15 +1721,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] name = "windows_x86_64_msvc" @@ -1775,9 +1733,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" [[package]] name = "winreg" @@ -1791,11 +1749,13 @@ dependencies = [ [[package]] name = "xattr" -version = "1.1.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc6ab6ec1907d1a901cdbcd2bd4cb9e7d64ce5c9739cbb97d3c391acd8c7fae" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", + "linux-raw-sys", + "rustix", ] [[package]] diff --git a/libprotonup/src/apps.rs b/libprotonup/src/apps.rs index f97896e..046099a 100644 --- a/libprotonup/src/apps.rs +++ b/libprotonup/src/apps.rs @@ -11,7 +11,7 @@ pub enum App { // TODO: HeroicGamesLauncher, } -// APP_VARIANTS is a shorthand to all app variants +/// APP_VARIANTS is a shorthand to all app variants pub static APP_VARIANTS: &[App] = &[App::Steam, App::Lutris]; impl fmt::Display for App { @@ -24,6 +24,7 @@ impl fmt::Display for App { } impl App { + /// Returns the version of Wine used for the App pub fn app_wine_version(&self) -> Variant { match *self { Self::Steam => Variant::GEProton, @@ -31,6 +32,7 @@ impl App { } } + /// Returns the variantst of AppInstallations corresponding to the App pub fn app_installations(&self) -> Vec { match *self { Self::Steam => vec![AppInstallations::Steam, AppInstallations::SteamFlatpak], @@ -38,6 +40,7 @@ impl App { } } + /// Checks the versions (Native vs Flatpak) of the App that are installed pub fn detect_installation_method(&self) -> Vec { match *self { Self::Steam => { @@ -70,6 +73,7 @@ impl fmt::Display for AppInstallations { } impl AppInstallations { + /// Default directory that wine is extracted to pub fn default_install_dir(&self) -> &'static str { match *self { Self::Steam => "~/.steam/steam/compatibilitytools.d/", @@ -81,6 +85,7 @@ impl AppInstallations { } } + /// The app root folder pub fn app_base_dir(&self) -> &'static str { match *self { Self::Steam => "~/.steam/steam/", @@ -90,10 +95,12 @@ impl AppInstallations { } } + /// Get a list of the currently installed wine versions pub fn list_installed_versions(&self) -> Result, anyhow::Error> { list_folders_in_path(self.default_install_dir()) } + /// Returns the base App pub fn into_app(&self) -> App { match *self { Self::Steam | Self::SteamFlatpak => App::Steam, @@ -107,7 +114,7 @@ pub fn list_installed_apps() -> Vec { detect_installations(APP_INSTALLATIONS_VARIANTS) } -/// detect_installations returns a vector of App variants that are detected based on the provided +/// detect_installations returns a vector of App variants that are detected fn detect_installations(app_installations: &[AppInstallations]) -> Vec { app_installations .iter() @@ -116,7 +123,7 @@ fn detect_installations(app_installations: &[AppInstallations]) -> Vec String { - let spath = path.to_str(); - match spath { - Some(p) => String::from(p), - None => String::from("path missing!"), - } -} - -// decompress will detect the extension and decompress the file with the appropriate function +/// decompress will detect the extension and decompress the file with the appropriate function pub fn decompress(from_path: &Path, destination_path: &Path) -> Result<()> { let path_str = from_path.as_os_str().to_string_lossy(); @@ -42,7 +34,7 @@ fn decompress_gz(from_path: &Path, destination_path: &Path) -> Result<()> { let file = File::open(from_path).with_context(|| { format!( "[Decompressing] Failed to open file from Path: {}", - path_result(from_path), + from_path.display(), ) })?; @@ -51,7 +43,7 @@ fn decompress_gz(from_path: &Path, destination_path: &Path) -> Result<()> { archive.unpack(destination_path).with_context(|| { format!( "[Decompressing] Failed to unpack into destination : {}", - path_result(destination_path) + destination_path.display() ) })?; Ok(()) @@ -62,7 +54,7 @@ fn decompress_xz(from_path: &Path, destination_path: &Path) -> Result<()> { let file = File::open(from_path).with_context(|| { format!( "[Decompressing] Failed to open file from Path: {}", - path_result(from_path), + from_path.display() ) })?; @@ -71,7 +63,7 @@ fn decompress_xz(from_path: &Path, destination_path: &Path) -> Result<()> { archive.unpack(destination_path).with_context(|| { format!( "[Decompressing] Failed to unpack into destination : {}", - path_result(destination_path) + destination_path.display() ) })?; Ok(()) @@ -85,20 +77,20 @@ pub fn create_progress_trackers() -> (Arc, Arc) { ) } -// check_if_exists checks if a folder exists in a path +/// check_if_exists checks if a folder exists in a path pub fn check_if_exists(path: &str, tag: &str) -> bool { let f_path = utils::expand_tilde(format!("{path}{tag}/")).unwrap(); let p = f_path.as_path(); p.is_dir() } -// list_folders_in_path returns a vector of strings of the folders in a path +/// list_folders_in_path returns a vector of strings of the folders in a path pub fn list_folders_in_path(path: &str) -> Result, anyhow::Error> { let f_path = utils::expand_tilde(path).unwrap(); let p = f_path.as_path(); let paths: Vec = p .read_dir() - .with_context(|| format!("Failed to read directory : {}", path_result(p)))? + .with_context(|| format!("Failed to read directory : {}", p.display()))? .filter_map(|e| e.ok()) .filter(|e| e.path().is_dir()) .map(|e| { @@ -110,12 +102,12 @@ pub fn list_folders_in_path(path: &str) -> Result, anyhow::Error> { Ok(paths) } -// removes a directory and all its contents +/// Removes a directory and all its contents pub fn remove_dir_all(path: &str) -> Result<()> { let f_path = utils::expand_tilde(path).unwrap(); let p = f_path.as_path(); std::fs::remove_dir_all(p) - .with_context(|| format!("[Remove] Failed to remove directory : {}", path_result(p)))?; + .with_context(|| format!("[Remove] Failed to remove directory : {}", p.display()))?; Ok(()) } @@ -143,7 +135,7 @@ pub async fn download_file_progress( .with_context(|| { format!( "[Download] Failed creating destination file : {}", - path_result(install_dir) + install_dir.display() ) })?; @@ -156,7 +148,7 @@ pub async fn download_file_progress( file.write_all(&chunk).with_context(|| { format!( "[Download] Failed creating destination file : {}", - path_result(install_dir) + install_dir.display() ) })?; let new = min(downloaded + (chunk.len() as u64), total_size); @@ -168,6 +160,7 @@ pub async fn download_file_progress( Ok(()) } +/// Downloads and returns the text response pub async fn download_file_into_memory(url: &String) -> Result { let client = reqwest::Client::new(); let res = client @@ -187,9 +180,10 @@ pub async fn download_file_into_memory(url: &String) -> Result { .with_context(|| format!("[Download SHA] Failed to read response from URL : {}", &url)) } +/// Checks the downloaded file integrity with the sha512sum pub fn hash_check_file(file_dir: String, git_hash: String) -> Result { let mut file = File::open(file_dir) - .context("[Hash Check] Failed oppening download file for checking. Was the file moved?")?; + .context("[Hash Check] Failed opening download file for checking. Was the file moved?")?; let mut hasher = Sha512::new(); io::copy(&mut file, &mut hasher) .context("[Hash Check] Failed reading download file for checking")?; diff --git a/libprotonup/src/github.rs b/libprotonup/src/github.rs index 7eed1db..033f573 100644 --- a/libprotonup/src/github.rs +++ b/libprotonup/src/github.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; pub type ReleaseList = Vec; +/// Contains the information from one of the releases on GitHub #[derive(Serialize, Deserialize, Debug)] pub struct Release { /// API URL of the Release @@ -40,6 +41,9 @@ impl Release { } } +/// Holds the information from the different Assets for each GitHub release +/// +/// An Asset could be for the wine tar folder or for the sha512sum #[derive(Serialize, Deserialize, Debug)] pub struct Asset { url: String, @@ -68,11 +72,15 @@ pub async fn list_releases( Ok(r_list) } +/// Contains all the information needed to download the corresponding release from GitHub #[derive(Default, Debug, PartialEq, Clone)] pub struct Download { pub version: String, + /// Download URL for the release's file hash to check download integrity pub sha512sum_url: String, + /// Download URL for the release's compressed tar file pub download_url: String, + /// The reported size of the tar download pub size: u64, } #[cfg(test)] diff --git a/libprotonup/src/variants.rs b/libprotonup/src/variants.rs index 6602482..13ed4cb 100644 --- a/libprotonup/src/variants.rs +++ b/libprotonup/src/variants.rs @@ -1,8 +1,11 @@ use super::constants::*; use std::{fmt, str::FromStr}; -/// Struct used to build GitHub api request URLs. -/// Contains the GitHub URL, username for GE, the repository name for either Wine GE or Proton GE, and a Variant Enum for identifying the parameters type +/// Struct used to build GitHub API request URLs. +/// +/// Contains the GitHub URL, the username for GE, +/// the repository name for either Wine GE or Proton GE, +/// and a Variant Enum for identifying the parameters type pub struct VariantGithubParameters { /// this is a link back to the enum variant variant_ref: Variant, @@ -44,7 +47,7 @@ pub enum Variant { } impl fmt::Display for Variant { - /// returns a string representation of this variant + /// Returns a string representation of this Variant fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Variant::GEProton => write!(f, "GEProton"), @@ -65,7 +68,7 @@ impl FromStr for Variant { } impl Variant { - /// returns the application target for the Variant. Steam and Lutris are the current options + /// Returns the application target for the Variant. Steam and Lutris are the current options pub fn intended_application(&self) -> &str { match self { Variant::GEProton => "Steam", @@ -92,5 +95,5 @@ impl Variant { } } -// ALL_VARIANTS is a shorthand to all app variants +/// ALL_VARIANTS is a shorthand to all app variants pub static ALL_VARIANTS: &[Variant] = &[Variant::GEProton, Variant::WineGE]; diff --git a/protonup-rs/src/download.rs b/protonup-rs/src/download.rs index 7cd3487..e05353e 100644 --- a/protonup-rs/src/download.rs +++ b/protonup-rs/src/download.rs @@ -19,6 +19,7 @@ use libprotonup::{ variants::{self, Variant}, }; +/// Downloads the requested file to the /tmp directory pub(crate) async fn download_file(download: Download) -> Result { let mut temp_dir = utils::expand_tilde(constants::TEMP_DIR).unwrap(); @@ -87,8 +88,11 @@ pub(crate) async fn download_file(download: Download) -> Result Ok(temp_dir) } +/// Prepares downloaded file to be decompressed +/// +/// Parses the passed in data and ensures the destination directory is created pub(crate) async fn unpack_file( - dowaload_path: &Path, + download_path: &Path, install_path: &str, wine_version: &Variant, ) -> Result<(), String> { @@ -97,7 +101,7 @@ pub(crate) async fn unpack_file( fs::create_dir_all(&install_dir).unwrap(); println!("Unpacking files into install location. Please wait"); - files::decompress(dowaload_path, install_dir.as_path()).unwrap(); + files::decompress(download_path, install_dir.as_path()).unwrap(); println!( "Done! Restart {}. {} installed in {}", wine_version.intended_application(), @@ -107,6 +111,7 @@ pub(crate) async fn unpack_file( Ok(()) } +/// Downloads the latest wine version for all the apps found pub async fn run_quick_downloads() { let found_apps = apps::list_installed_apps(); if found_apps.is_empty() { @@ -157,6 +162,7 @@ pub async fn run_quick_downloads() { } /// Start the Download for the selected app +/// /// If no app is provided, the user is prompted for which version of Wine/Proton to use and what directory to extract to pub async fn download_to_selected_app(app: Option) { // Get the version of Wine/Proton to install @@ -181,7 +187,6 @@ pub async fn download_to_selected_app(app: Option) { std::process::exit(0); } - // Figure out which versions of the App the user has (Native/Flatpak) installed_apps if installed_apps.len() == 1 => { println!( @@ -227,8 +232,6 @@ pub async fn download_to_selected_app(app: Option) { } }; - // versions_to_install = vec![]; - // Let the user choose which releases they want to use let mut release_list = match helper_menus::multiple_select_menu( "Select the versions you want to download :", @@ -265,6 +268,7 @@ pub async fn download_to_selected_app(app: Option) { } /// Checks if the selected Release/version is already installed. +/// /// Will prompt the user to overwrite existing files async fn check_if_already_downloaded(release_list: &mut Vec, install_dir: &str) { release_list.retain(|release| { diff --git a/protonup-rs/src/file_path.rs b/protonup-rs/src/file_path.rs index 4f863aa..5e34b8b 100644 --- a/protonup-rs/src/file_path.rs +++ b/protonup-rs/src/file_path.rs @@ -76,10 +76,11 @@ impl FilePathCompleter { let mut ret: String = String::new(); let mut sorted = self.paths.clone(); - sorted.sort(); if sorted.is_empty() { return ret; } + sorted.sort(); + let mut first_word = sorted.first().unwrap().chars(); let mut last_word = sorted.last().unwrap().chars(); diff --git a/protonup-rs/src/helper_menus.rs b/protonup-rs/src/helper_menus.rs index db8c9dd..c57d9d9 100644 --- a/protonup-rs/src/helper_menus.rs +++ b/protonup-rs/src/helper_menus.rs @@ -1,6 +1,8 @@ use inquire::{Confirm, InquireError, MultiSelect}; -/// Creates a inquire::MultiSelect menu with the first option selected +/// Prompt the user to select multiple possible options with an inquire::MultiSelect menu +/// +/// The first option is selected pub(crate) fn multiple_select_menu( message: &str, options: Vec, @@ -13,6 +15,9 @@ where .prompt() } +/// Prompt the user [Y/n] with an inquire::Confirm menu +/// +/// `help_text` and `default` are used to set default values pub(crate) fn confirm_menu(text: String, help_text: String, default: bool) -> bool { let answer = Confirm::new(&text) .with_default(default) diff --git a/protonup-rs/src/main.rs b/protonup-rs/src/main.rs index c12f8cb..cf18ce3 100644 --- a/protonup-rs/src/main.rs +++ b/protonup-rs/src/main.rs @@ -73,9 +73,15 @@ async fn main() { // Set parameters based on users choice match answer { InitialMenu::QuickUpdate => download::run_quick_downloads().await, - InitialMenu::DownloadForSteam => download::download_to_selected_app(Some(App::Steam)).await, - InitialMenu::DownloadForLutris => download::download_to_selected_app(Some(App::Lutris)).await, - InitialMenu::DownloadIntoCustomLocation => download::download_to_selected_app(None).await, + InitialMenu::DownloadForSteam => { + download::download_to_selected_app(Some(App::Steam)).await + } + InitialMenu::DownloadForLutris => { + download::download_to_selected_app(Some(App::Lutris)).await + } + InitialMenu::DownloadIntoCustomLocation => { + download::download_to_selected_app(None).await + } InitialMenu::ManageExistingInstallations => manage_apps_routine(), } } diff --git a/protonup-rs/src/manage_apps.rs b/protonup-rs/src/manage_apps.rs index d419c56..bb40c9a 100644 --- a/protonup-rs/src/manage_apps.rs +++ b/protonup-rs/src/manage_apps.rs @@ -10,7 +10,7 @@ pub(crate) enum ManageAppsMenuOptions { AppInstallations(apps::AppInstallations), } -// APP_VARIANTS_WITH_DETECT contains all variants of the App enum including the DetectAll variant +/// APP_VARIANTS_WITH_DETECT contains all variants of the App enum including the DetectAll variant static APP_VARIANTS_WITH_DETECT: &[ManageAppsMenuOptions] = &[ ManageAppsMenuOptions::DetectAll, ManageAppsMenuOptions::AppInstallations(apps::AppInstallations::Steam), @@ -28,6 +28,7 @@ impl fmt::Display for ManageAppsMenuOptions { } } +/// Prompt the user for which App they want to manage fn manage_menu() -> Vec { let answer = MultiSelect::new( "Select the Applications you want to manage :", @@ -46,6 +47,9 @@ fn manage_menu() -> Vec { } } +/// Allow the user to delete existing wine versions +/// +/// The user selects the apps and wine versions to remove pub(crate) fn manage_apps_routine() { let mut apps = vec![];