From 56771991becee7b0cd386479eefffea3e524b8c2 Mon Sep 17 00:00:00 2001 From: MordechaiHadad <33547558+MordechaiHadad@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:09:03 +0300 Subject: [PATCH 1/8] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad6e71d..d78b15f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ jobs: check: strategy: matrix: - os: [macos-latest, windows-latest, ubuntu-latest, macos-13] + os: [macos-latest, windows-latest, ubuntu-latest] runs-on: ${{matrix.os}} steps: - name: Checkout @@ -91,7 +91,7 @@ jobs: } - { NAME: macos, - OS: macos-latest-large, + OS: macos-13, PATH: target/optimized/bob, } - { NAME: windows, OS: windows-latest, PATH: build } From 291e4e08806351a945e884dacd27aefdcf3963a2 Mon Sep 17 00:00:00 2001 From: morde Date: Tue, 10 Sep 2024 14:09:32 +0300 Subject: [PATCH 2/8] fix: give a better notification when updating bob proxy --- Cargo.lock | 213 ++++++++++++++++++++---------------- Cargo.toml | 2 +- src/handlers/use_handler.rs | 15 ++- 3 files changed, 132 insertions(+), 98 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ab430e..3741588 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "async-recursion" @@ -124,17 +124,17 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "bob-nvim" -version = "4.0.1" +version = "4.0.2" dependencies = [ "anyhow", "async-recursion", @@ -238,9 +238,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -271,9 +274,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.13" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -281,9 +284,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -293,9 +296,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.12" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8670053e87c316345e384ca1f3eba3006fc6355ed8b8a1140d104e109e3df34" +checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" dependencies = [ "clap", ] @@ -349,15 +352,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -434,27 +437,27 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", + "libredox", + "windows-sys 0.59.0", ] [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "miniz_oxide", @@ -574,9 +577,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "h2" @@ -735,9 +738,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", @@ -757,9 +760,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is_terminal_polyfill" @@ -775,9 +778,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -790,9 +793,20 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall", +] [[package]] name = "linux-raw-sys" @@ -839,18 +853,18 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", @@ -904,9 +918,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -979,7 +993,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall", "smallvec", "windows-targets 0.52.6", ] @@ -1028,9 +1042,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1065,15 +1079,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.5.3" @@ -1197,9 +1202,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", @@ -1259,11 +1264,11 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1313,18 +1318,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1333,9 +1338,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1390,6 +1395,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -1448,9 +1459,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -1497,15 +1508,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1566,9 +1577,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -1615,9 +1626,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -1662,9 +1673,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -1844,19 +1855,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -1869,9 +1881,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -1881,9 +1893,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1891,9 +1903,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -1904,9 +1916,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" @@ -1923,9 +1935,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -1986,6 +1998,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" diff --git a/Cargo.toml b/Cargo.toml index ca1df96..1313f17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bob-nvim" edition = "2021" -version = "4.0.1" +version = "4.0.2" description = "A version manager for neovim" readme = "README.md" keywords = ["neovim", "version-manager"] diff --git a/src/handlers/use_handler.rs b/src/handlers/use_handler.rs index 975b45b..c4cfd07 100644 --- a/src/handlers/use_handler.rs +++ b/src/handlers/use_handler.rs @@ -215,11 +215,24 @@ async fn copy_nvim_proxy(config: &Config) -> Result<()> { } info!("Updating neovim proxy"); - fs::copy(&exe_path, &installation_dir).await?; + copy_file_with_error_handling(&exe_path, &installation_dir).await?; Ok(()) } +async fn copy_file_with_error_handling(old_path: &Path, new_path: &Path) -> Result<()> { + match fs::copy(&old_path, &new_path).await { + Ok(_) => Ok(()), + Err(e) => match e.raw_os_error() { + Some(26) | Some(32) => { + eprintln!("Error: The file is busy. Please make sure to close any processes using it."); + Err(anyhow::anyhow!("The file {} is busy. Please make sure to close any processes using it.", old_path.display())) + } + _ => Err(anyhow::anyhow!(e).context("Failed to copy file")), + }, + } +} + /// Adds the installation directory to the system's PATH. /// /// This function checks if the installation directory is already in the PATH. If not, it adds the directory to the PATH. From 435f3de175ecf87cc540643170f697c96ce1aef7 Mon Sep 17 00:00:00 2001 From: morde Date: Tue, 10 Sep 2024 14:14:20 +0300 Subject: [PATCH 3/8] chores --- src/handlers/use_handler.rs | 56 +++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/src/handlers/use_handler.rs b/src/handlers/use_handler.rs index c4cfd07..2ba9111 100644 --- a/src/handlers/use_handler.rs +++ b/src/handlers/use_handler.rs @@ -220,16 +220,60 @@ async fn copy_nvim_proxy(config: &Config) -> Result<()> { Ok(()) } +/// Asynchronously copies a file from `old_path` to `new_path`, handling specific OS errors. +/// +/// This function attempts to copy a file from the specified `old_path` to the specified `new_path`. +/// If the file is being used by another process (OS error 26 or 32), it prints an error message +/// and returns an error indicating that the file is busy. For any other errors, it returns a +/// generic error with additional context. +/// +/// # Arguments +/// +/// * `old_path` - A reference to the source `Path` of the file to be copied. +/// * `new_path` - A reference to the destination `Path` where the file should be copied. +/// +/// # Returns +/// +/// This function returns a `Result<()>`. If the file is successfully copied, it returns `Ok(())`. +/// If an error occurs, it returns an `Err` with a detailed error message. +/// +/// # Errors +/// +/// This function will return an error in the following cases: +/// - If the file is being used by another process (OS error 26 or 32), it returns an error +/// indicating that the file is busy. +/// - For any other errors, it returns a generic error with additional context. +/// +/// # Examples +/// +/// ```rust +/// use std::path::Path; +/// use anyhow::Result; +/// +/// #[tokio::main] +/// async fn main() -> Result<()> { +/// let old_path = Path::new("path/to/source/file"); +/// let new_path = Path::new("path/to/destination/file"); +/// +/// copy_file_with_error_handling(&old_path, &new_path).await?; +/// Ok(()) +/// } +/// ``` async fn copy_file_with_error_handling(old_path: &Path, new_path: &Path) -> Result<()> { match fs::copy(&old_path, &new_path).await { Ok(_) => Ok(()), - Err(e) => match e.raw_os_error() { - Some(26) | Some(32) => { - eprintln!("Error: The file is busy. Please make sure to close any processes using it."); - Err(anyhow::anyhow!("The file {} is busy. Please make sure to close any processes using it.", old_path.display())) + Err(e) => { + match e.raw_os_error() { + Some(26) | Some(32) => { + eprintln!("Error: The file is busy. Please make sure to close any processes using it."); + Err(anyhow::anyhow!( + "The file {} is busy. Please make sure to close any processes using it.", + old_path.display() + )) + } + _ => Err(anyhow::anyhow!(e).context("Failed to copy file")), } - _ => Err(anyhow::anyhow!(e).context("Failed to copy file")), - }, + } } } From 9df5d541d2bb50c7c873aae8a0b5d65290c4792c Mon Sep 17 00:00:00 2001 From: MordechaiHadad <33547558+MordechaiHadad@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:41:58 +0300 Subject: [PATCH 4/8] Update ci.yml --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad6e71d..41a53f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,17 +87,20 @@ jobs: - { NAME: linux, OS: ubuntu-latest, + ARCH: x86_64, PATH: target/optimized/bob, } - { NAME: macos, OS: macos-latest-large, + ARCH: x86_64, PATH: target/optimized/bob, } - - { NAME: windows, OS: windows-latest, PATH: build } + - { NAME: windows, OS: windows-latest, ARCH: x86_64, PATH: build } - { NAME: macos-arm, OS: macos-latest, + ARCH: arm, PATH: target/optimized/bob, } tls: @@ -134,7 +137,7 @@ jobs: - name: Upload Bob binary uses: actions/upload-artifact@v4 with: - name: "bob-${{ matrix.os.NAME }}-x86_64${{ matrix.tls.SUFFIX }}" + name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}-${{ matrix.tls.SUFFIX }}" path: ${{ matrix.os.PATH }} if-no-files-found: error retention-days: 7 From 3572df13dea1738d8d475c73a8cc76403f6bd96b Mon Sep 17 00:00:00 2001 From: MordechaiHadad Date: Wed, 11 Sep 2024 10:47:12 +0300 Subject: [PATCH 5/8] remove the print statement --- src/handlers/use_handler.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/handlers/use_handler.rs b/src/handlers/use_handler.rs index 2ba9111..f16e389 100644 --- a/src/handlers/use_handler.rs +++ b/src/handlers/use_handler.rs @@ -265,7 +265,6 @@ async fn copy_file_with_error_handling(old_path: &Path, new_path: &Path) -> Resu Err(e) => { match e.raw_os_error() { Some(26) | Some(32) => { - eprintln!("Error: The file is busy. Please make sure to close any processes using it."); Err(anyhow::anyhow!( "The file {} is busy. Please make sure to close any processes using it.", old_path.display() From d6d56161494a8b7fd5f6dfaa99d3c521d10f3806 Mon Sep 17 00:00:00 2001 From: morde Date: Wed, 11 Sep 2024 10:50:05 +0300 Subject: [PATCH 6/8] bruh --- .github/workflows/ci.yml | 2 +- src/handlers/use_handler.rs | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41a53f3..6d67c14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: } - { NAME: macos, - OS: macos-latest-large, + OS: macos-13, ARCH: x86_64, PATH: target/optimized/bob, } diff --git a/src/handlers/use_handler.rs b/src/handlers/use_handler.rs index f16e389..7908ea9 100644 --- a/src/handlers/use_handler.rs +++ b/src/handlers/use_handler.rs @@ -262,17 +262,13 @@ async fn copy_nvim_proxy(config: &Config) -> Result<()> { async fn copy_file_with_error_handling(old_path: &Path, new_path: &Path) -> Result<()> { match fs::copy(&old_path, &new_path).await { Ok(_) => Ok(()), - Err(e) => { - match e.raw_os_error() { - Some(26) | Some(32) => { - Err(anyhow::anyhow!( - "The file {} is busy. Please make sure to close any processes using it.", - old_path.display() - )) - } - _ => Err(anyhow::anyhow!(e).context("Failed to copy file")), - } - } + Err(e) => match e.raw_os_error() { + Some(26) | Some(32) => Err(anyhow::anyhow!( + "The file {} is busy. Please make sure to close any processes using it.", + old_path.display() + )), + _ => Err(anyhow::anyhow!(e).context("Failed to copy file")), + }, } } From 306e5f64395d149580589052bf116f32ae062dd1 Mon Sep 17 00:00:00 2001 From: morde Date: Wed, 11 Sep 2024 11:23:53 +0300 Subject: [PATCH 7/8] i understand nothing --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d67c14..9f610ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,7 +98,7 @@ jobs: } - { NAME: windows, OS: windows-latest, ARCH: x86_64, PATH: build } - { - NAME: macos-arm, + NAME: macos, OS: macos-latest, ARCH: arm, PATH: target/optimized/bob, @@ -137,7 +137,7 @@ jobs: - name: Upload Bob binary uses: actions/upload-artifact@v4 with: - name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}-${{ matrix.tls.SUFFIX }}" + name: "bob-${{ matrix.os.NAME }}${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}" path: ${{ matrix.os.PATH }} if-no-files-found: error retention-days: 7 From 88a79858a615cc11655446ef2b57480757fd71b7 Mon Sep 17 00:00:00 2001 From: morde Date: Wed, 11 Sep 2024 11:43:14 +0300 Subject: [PATCH 8/8] lol --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f610ea..cfc97ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,7 +137,7 @@ jobs: - name: Upload Bob binary uses: actions/upload-artifact@v4 with: - name: "bob-${{ matrix.os.NAME }}${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}" + name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}" path: ${{ matrix.os.PATH }} if-no-files-found: error retention-days: 7