diff --git a/core/src/ten_manager/Cargo.lock b/core/src/ten_manager/Cargo.lock index 6ac5dae1a..43ab0959d 100644 --- a/core/src/ten_manager/Cargo.lock +++ b/core/src/ten_manager/Cargo.lock @@ -228,9 +228,9 @@ dependencies = [ [[package]] name = "actix_derive" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7db3d5a9718568e4cf4a537cfd7070e6e6ff7481510d0237fb529ac850f6d3" +checksum = "b6ac1e58cded18cb28ddc17143c4dea5345b3ad575e14f32f66e4054a56eb271" dependencies = [ "proc-macro2", "quote", @@ -239,19 +239,13 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -367,9 +361,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "arbitrary" @@ -391,23 +385,23 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[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 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -523,9 +517,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bytestring" @@ -538,9 +532,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.15" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -591,18 +585,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -691,9 +685,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -902,9 +896,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] @@ -944,12 +938,12 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -993,9 +987,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1003,36 +997,48 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-io", + "futures-macro", "futures-sink", "futures-task", "memchr", @@ -1084,9 +1090,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -1096,9 +1102,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", @@ -1128,9 +1134,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "5.1.2" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +checksum = "ce25b617d1375ef96eeb920ae717e3da34a02fc979fe632c75128350f9e1f74a" dependencies = [ "log", "pest", @@ -1142,9 +1148,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "hermit-abi" @@ -1208,9 +1214,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -1220,9 +1226,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -1239,9 +1245,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", @@ -1257,9 +1263,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1270,7 +1276,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1287,9 +1292,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" dependencies = [ "crossbeam-deque", "globset", @@ -1303,15 +1308,15 @@ dependencies = [ [[package]] name = "impl-more" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" +checksum = "aae21c3177a27788957044151cc2800043d127acaa460a47ebb9b84dfa2c6aa0" [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown", @@ -1367,9 +1372,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is_terminal_polyfill" @@ -1412,9 +1417,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -1432,9 +1437,9 @@ dependencies = [ [[package]] name = "jsonschema" -version = "0.18.1" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f037c58cadb17e8591b620b523cc6a7ab2b91b6ce3121f8eb4171f8d80115c" +checksum = "fa0f4bea31643be4c6a678e9aa4ae44f0db9e5609d5ca9dc9083d06eb3e9a27a" dependencies = [ "ahash", "anyhow", @@ -1472,9 +1477,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" @@ -1597,15 +1602,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -1773,18 +1769,18 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "option-ext" @@ -1839,9 +1835,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -1850,9 +1846,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" dependencies = [ "pest", "pest_generator", @@ -1860,9 +1856,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" dependencies = [ "pest", "pest_meta", @@ -1873,40 +1869,20 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" dependencies = [ "once_cell", "pest", "sha2", ] -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -1916,15 +1892,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -1943,9 +1919,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", "syn", @@ -1953,18 +1929,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "quinn" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d2fb862b7ba45e615c1429def928f2e15f815bdf933b27a2d3824e224c1f46" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "pin-project-lite", @@ -1980,9 +1956,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0a9b3a42929fad8a7c3de7f86ce0814cfa893328157672680e9fb1145549c5" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", @@ -1997,15 +1973,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2049,9 +2025,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -2069,9 +2045,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -2081,9 +2057,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -2098,29 +2074,29 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remove_dir_all" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c914caef075f03e9d5c568e2e71b3d3cf17dc61a5481ff379bb744721be0a75a" +checksum = "a694f9e0eb3104451127f6cc1e5de55f59d3b1fc8c5ddfaeb6f1e716479ceb4a" dependencies = [ "cfg-if", "cvt", "fs_at", "libc", "normpath", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64", "bytes", @@ -2203,9 +2179,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -2216,9 +2192,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "once_cell", "ring", @@ -2230,25 +2206,24 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -2287,18 +2262,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.209" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -2307,9 +2282,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap", "itoa", @@ -2445,9 +2420,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.77" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -2465,9 +2440,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -2489,6 +2464,7 @@ dependencies = [ "clingo", "console", "dirs", + "futures-util", "globset", "handlebars", "ignore", @@ -2531,18 +2507,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", @@ -2607,9 +2583,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -2647,9 +2623,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", @@ -2658,27 +2634,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -2719,42 +2674,42 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "untrusted" @@ -2781,9 +2736,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "vec1" @@ -2824,9 +2779,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -2835,9 +2790,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -2850,9 +2805,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -2862,9 +2817,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2872,9 +2827,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -2885,15 +2840,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -2901,9 +2856,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] diff --git a/core/src/ten_manager/Cargo.toml b/core/src/ten_manager/Cargo.toml index 54ef3887d..0d766c39f 100644 --- a/core/src/ten_manager/Cargo.toml +++ b/core/src/ten_manager/Cargo.toml @@ -22,7 +22,7 @@ zip = { version = "2.1", default-features = false, features = [ "zstd", ] } anyhow = "1.0" -handlebars = "5.1" +handlebars = "6.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" clap = "4.5" @@ -31,7 +31,7 @@ walkdir = "2.5" tempfile = "3.10" sha2 = "0.10" clingo = { version = "0.8" } -regex = "1.10" +regex = "1.11" remove_dir_all = "0.8" dirs = "5.0" tokio = { version = "1", features = ["full"] } @@ -47,6 +47,7 @@ indicatif = "0.17" console = "0.15" ten_rust = { path = "../ten_rust", version = "0.1.0" } inquire = "0.7.5" +futures-util = "0.3" [target.'cfg(unix)'.dependencies] mimalloc = "0.1" diff --git a/core/src/ten_manager/src/registry/remote.rs b/core/src/ten_manager/src/registry/remote.rs index c7c855ac2..fe272530a 100644 --- a/core/src/ten_manager/src/registry/remote.rs +++ b/core/src/ten_manager/src/registry/remote.rs @@ -4,7 +4,10 @@ // Licensed under the Apache License, Version 2.0, with certain conditions. // Refer to the "LICENSE" file in the root directory for more information. // -use std::{io::Write, path::PathBuf}; +use std::cell::RefCell; +use std::rc::Rc; +use std::{io::Write, path::PathBuf, time::Duration}; +use tokio::time::sleep; use anyhow::{anyhow, Context, Result}; use reqwest::header::{HeaderMap, AUTHORIZATION, CONTENT_TYPE}; @@ -23,6 +26,40 @@ use ten_rust::pkg_info::{ PkgInfo, }; +async fn retry_async<'a, F, T>( + tman_config: &TmanConfig, + max_retries: u32, + retry_delay: Duration, + mut operation: F, +) -> Result +where + F: FnMut() -> std::pin::Pin< + Box> + 'a>, + >, +{ + for attempt in 0..=max_retries { + match operation().await { + Ok(result) => return Ok(result), + Err(e) => { + tman_verbose_println!( + tman_config, + "Attempt {} failed: {:?}", + attempt + 1, + e + ); + + if attempt == max_retries { + return Err(e); + } + + sleep(retry_delay).await; + } + } + } + + unreachable!("retry logic should either return or error out") +} + #[derive(Debug)] struct UploadInfo { resource_id: String, @@ -51,148 +88,196 @@ async fn get_package_upload_info( // TODO: Implement the 'environments' mechanism. // Add a new environments field, or perhaps directly upload the content of // manifest.json to the cloud store. - let payload = json!(RegistryPackageData { - pkg_type: pkg_info.pkg_identity.pkg_type.clone(), - name: pkg_info.pkg_identity.name.clone(), - version: pkg_info.version.clone(), - dependencies: pkg_info - .dependencies - .clone() - .into_iter() - .map(|d| d.into()) - .collect(), - supports: Some(get_manifest_supports_from_pkg(&pkg_info.supports)), - hash: pkg_info.hash.clone(), - }); - - tman_verbose_println!( - tman_config, - "Payload of publishing: {}", - payload.to_string() - ); - - let mut headers = HeaderMap::new(); - - if let Some(user_token) = &tman_config.user_token { - let basic_token = format!("Basic {}", user_token); - headers.insert( - AUTHORIZATION, - basic_token.parse().map_err(|e| { - eprintln!("Failed to parse authorization token: {}", e); - e - })?, - ); - } else { - tman_verbose_println!(tman_config, "Authorization token is missing"); - return Err(TmanError::Custom( - "Authorization token is missing".to_string(), - ) - .into()); - } - let response = client - .post(base_url) - .headers(headers) - .json(&payload) - .send() - .await - .map_err(|e| anyhow!("Failed to send request: {}", e))?; - - if !response.status().is_success() { - return Err(anyhow!( - "Received non-success status code: {}", - response.status(), - )); - } + let max_retries = 3; + let retry_delay = Duration::from_millis(100); + + retry_async(tman_config, max_retries, retry_delay, || { + let base_url = base_url.to_string(); + let client = client.clone(); + let pkg_info = pkg_info.clone(); + + Box::pin(async move { + let payload = json!(RegistryPackageData { + pkg_type: pkg_info.pkg_identity.pkg_type.clone(), + name: pkg_info.pkg_identity.name.clone(), + version: pkg_info.version.clone(), + dependencies: pkg_info + .dependencies + .clone() + .into_iter() + .map(|d| d.into()) + .collect(), + supports: Some(get_manifest_supports_from_pkg( + &pkg_info.supports + )), + hash: pkg_info.hash.clone(), + }); + + tman_verbose_println!( + tman_config, + "Payload of publishing: {}", + payload.to_string() + ); + + let mut headers = HeaderMap::new(); + + if let Some(user_token) = &tman_config.user_token { + let basic_token = format!("Basic {}", user_token); + headers.insert( + AUTHORIZATION, + basic_token.parse().map_err(|e| { + eprintln!("Failed to parse authorization token: {}", e); + e + })?, + ); + } else { + tman_verbose_println!( + tman_config, + "Authorization token is missing" + ); + return Err(TmanError::Custom( + "Authorization token is missing".to_string(), + ) + .into()); + } + + let response = client + .post(base_url) + .headers(headers) + .json(&payload) + .send() + .await + .map_err(|e| anyhow!("Failed to send request: {}", e))?; + + if !response.status().is_success() { + return Err(anyhow!( + "Received non-success status code: {}", + response.status(), + )); + } - let data: Value = response - .json() - .await - .map_err(|e| anyhow!("Failed to parse JSON response: {}", e))?; - - let resource_id = data["data"]["resourceId"] - .as_str() - .ok_or_else(|| anyhow!("Missing 'resourceId' in response"))? - .to_string(); - let url = data["data"]["url"] - .as_str() - .ok_or_else(|| anyhow!("Missing 'url' in response"))? - .to_string(); - - Ok(UploadInfo { resource_id, url }) + let data: Value = response + .json() + .await + .map_err(|e| anyhow!("Failed to parse JSON response: {}", e))?; + + let resource_id = data["data"]["resourceId"] + .as_str() + .ok_or_else(|| anyhow!("Missing 'resourceId' in response"))? + .to_string(); + let url = data["data"]["url"] + .as_str() + .ok_or_else(|| anyhow!("Missing 'url' in response"))? + .to_string(); + + Ok(UploadInfo { resource_id, url }) + }) + }) + .await } async fn upload_package_to_remote( + tman_config: &TmanConfig, client: &reqwest::Client, package_file_path: &str, url: &str, ) -> Result<()> { - let body = match std::fs::read(package_file_path) { - Ok(file) => file, - Err(e) => { - eprintln!("Failed to read file at '{}': {}", package_file_path, e); - return Err(e.into()); - } - }; - - let mut headers = HeaderMap::new(); - - headers.insert( - CONTENT_TYPE, - "application/zip".parse().map_err(|e| { - eprintln!("Failed to parse content type: {}", e); - e - })?, - ); - - let response = client.put(url).headers(headers).body(body).send().await; - match response { - Ok(resp) => { - if resp.status().is_success() { - Ok(()) - } else { - Err(TmanError::Custom(format!( - "Failed to upload package with HTTP status {:?}", - resp.text().await - )) - .into()) + let max_retries = 3; + let retry_delay = Duration::from_millis(100); + + retry_async(tman_config, max_retries, retry_delay, || { + let client = client.clone(); + let package_file_path = package_file_path.to_string(); + let url = url.to_string(); + + Box::pin(async move { + let body = match std::fs::read(&package_file_path) { + Ok(file) => file, + Err(e) => { + eprintln!( + "Failed to read file at '{}': {}", + &package_file_path, e + ); + return Err(e.into()); + } + }; + + let mut headers = HeaderMap::new(); + + headers.insert( + CONTENT_TYPE, + "application/zip".parse().map_err(|e| { + eprintln!("Failed to parse content type: {}", e); + e + })?, + ); + + let response = + client.put(url).headers(headers).body(body).send().await; + match response { + Ok(resp) => { + if resp.status().is_success() { + Ok(()) + } else { + Err(TmanError::Custom(format!( + "Failed to upload package with HTTP status {:?}", + resp.text().await + )) + .into()) + } + } + Err(e) => Err(e.into()), } - } - Err(e) => Err(e.into()), - } + }) + }) + .await } async fn ack_of_uploading( + tman_config: &TmanConfig, base_url: &str, client: &reqwest::Client, resource_id: &str, ) -> Result<()> { - let url = match reqwest::Url::parse(base_url) { - Ok(url) => url, - Err(e) => { - eprintln!("Invalid base URL: {}", e); - return Err(e.into()); - } - }; - - let body = json!({ "resourceId": resource_id }); - - let response = client.patch(url).json(&body).send().await; - - match response { - Ok(resp) => { - if resp.status().is_success() { - Ok(()) - } else { - Err(TmanError::Custom(format!( + let max_retries = 3; + let retry_delay = Duration::from_millis(100); + + retry_async(tman_config, max_retries, retry_delay, || { + let base_url = base_url.to_string(); + let client = client.clone(); + let resource_id = resource_id.to_string(); + + Box::pin(async move { + let url = match reqwest::Url::parse(&base_url) { + Ok(url) => url, + Err(e) => { + eprintln!("Invalid base URL: {}", e); + return Err(e.into()); + } + }; + + let body = json!({ "resourceId": resource_id }); + + let response = client.patch(url).json(&body).send().await; + + match response { + Ok(resp) => { + if resp.status().is_success() { + Ok(()) + } else { + Err(TmanError::Custom(format!( "Failed to acknowledge uploading with HTTP status {}", resp.status() )) - .into()) + .into()) + } + } + Err(e) => Err(e.into()), } - } - Err(e) => Err(e.into()), - } + }) + }) + .await } pub async fn upload_package( @@ -206,49 +291,77 @@ pub async fn upload_package( let upload_info = get_package_upload_info(tman_config, base_url, &client, pkg_info) .await?; - upload_package_to_remote(&client, package_file_path, &upload_info.url) + + upload_package_to_remote( + tman_config, + &client, + package_file_path, + &upload_info.url, + ) + .await?; + + ack_of_uploading(tman_config, base_url, &client, &upload_info.resource_id) .await?; - ack_of_uploading(base_url, &client, &upload_info.resource_id).await?; Ok(()) } -pub async fn get_package( +pub async fn get_package<'a>( tman_config: &TmanConfig, url: &str, - temp_path: &mut NamedTempFile, + temp_path: &'a mut NamedTempFile, ) -> Result<()> { let client = reqwest::Client::new(); - let response = - client.get(url).send().await.with_context(|| { - format!("Failed to send GET request to {}", url) - })?; - - if !response.status().is_success() { - return Err(anyhow!( - "Failed to download the package: HTTP {}", - response.status() - )); - } - - let content = response - .bytes() - .await - .with_context(|| "Failed to read bytes from response")?; - - temp_path - .write_all(&content) - .with_context(|| "Failed to write content to temporary file")?; - - tman_verbose_println!( - tman_config, - "Package downloaded successfully from {} and written to {}", - url, - temp_path.path().display() - ); + // Wrap the temp_file in an Rc> to allow mutable borrowing inside + // the async closure. + let temp_path = Rc::new(RefCell::new(temp_path)); + + let max_retries = 3; + let retry_delay = Duration::from_millis(100); + + // Pass the Rc> into the retry logic + retry_async(tman_config, max_retries, retry_delay, || { + let client = client.clone(); + let url = url.to_string(); + let temp_path = Rc::clone(&temp_path); // Clone the Rc pointer. + + Box::pin(async move { + let response = + client.get(&url).send().await.with_context(|| { + format!("Failed to send GET request to {}", url) + })?; + + if !response.status().is_success() { + return Err(anyhow!( + "Failed to download the package: HTTP {}", + response.status() + )); + } - Ok(()) + let content = response + .bytes() + .await + .with_context(|| "Failed to read bytes from response")?; + + // Mutably borrow temp_file inside the async block. + let mut temp_path_borrow = temp_path.borrow_mut(); + + temp_path_borrow + .write_all(&content) + .with_context(|| "Failed to write content to temporary file")?; + + tman_verbose_println!( + tman_config, + "Package downloaded successfully from {} and written to {}", + url, + temp_path_borrow.path().display() + ); + + Ok(()) + }) + }) + .await } #[derive(Debug, Serialize, Deserialize)] @@ -271,84 +384,96 @@ pub async fn get_package_list( pkg_identity: &PkgIdentity, criteria: &SearchCriteria, ) -> Result> { - let client = reqwest::Client::new(); - - let mut results = Vec::new(); - let mut current_page = 1; - let mut total_size; - - loop { - let mut url = reqwest::Url::parse(base_url)?; - url.query_pairs_mut() - .append_pair("type", &pkg_identity.pkg_type.to_string()) - .append_pair("name", &pkg_identity.name) - .append_pair("version", &criteria.version_req.to_string()) - .append_pair("pageSize", "10") - .append_pair("page", ¤t_page.to_string()); - - let response = client.get(url).send().await; - - let response = match response { - Ok(response) => response, - Err(e) => return Err(anyhow::anyhow!("Request failed: {}", e)), - }; - - if response.status() != reqwest::StatusCode::OK { - return Err(anyhow::anyhow!( - "API responded with non-ok status: {}", - response.status() - )); - } - - let body = response.text().await?; - let api_response = serde_json::from_str::(&body); - let api_response = match api_response { - Ok(api_response) => api_response, - Err(e) => { - return Err(anyhow::anyhow!( - "Failed to parse JSON response: {}", - e - )) + let max_retries = 3; + let retry_delay = Duration::from_millis(100); + + retry_async(tman_config, max_retries, retry_delay, || { + let base_url = base_url.to_string(); + let pkg_identity = pkg_identity.clone(); + let client = reqwest::Client::new(); + + Box::pin(async move { + let mut results = Vec::new(); + let mut current_page = 1; + let mut total_size; + + loop { + let mut url = reqwest::Url::parse(&base_url)?; + url.query_pairs_mut() + .append_pair("type", &pkg_identity.pkg_type.to_string()) + .append_pair("name", &pkg_identity.name) + .append_pair("version", &criteria.version_req.to_string()) + .append_pair("pageSize", "10") + .append_pair("page", ¤t_page.to_string()); + + let response = client.get(url).send().await; + + let response = match response { + Ok(response) => response, + Err(e) => { + return Err(anyhow::anyhow!("Request failed: {}", e)) + } + }; + + if response.status() != reqwest::StatusCode::OK { + return Err(anyhow::anyhow!( + "API responded with non-ok status: {}", + response.status() + )); + } + + let body = response.text().await?; + let api_response = serde_json::from_str::(&body); + let api_response = match api_response { + Ok(api_response) => api_response, + Err(e) => { + return Err(anyhow::anyhow!( + "Failed to parse JSON response: {}", + e + )) + } + }; + + if api_response.status != "ok" { + return Err(anyhow::anyhow!( + "API responded with non-ok status: {}", + api_response.status + )); + } + + total_size = api_response.data.total_size as usize; + + for package_data in api_response.data.packages { + let url = PathBuf::from(format!( + "{}/{}/{}/{}/{}", + &base_url, + package_data.pkg_type, + package_data.name, + package_data.version, + package_data.hash, + )); + results.push(FoundResult { url, package_data }); + } + + // Check if we've fetched all packages based on totalSize. + if results.len() >= total_size { + break; + } + current_page += 1; } - }; - - if api_response.status != "ok" { - return Err(anyhow::anyhow!( - "API responded with non-ok status: {}", - api_response.status - )); - } - total_size = api_response.data.total_size as usize; - - for package_data in api_response.data.packages { - let url = PathBuf::from(format!( - "{}/{}/{}/{}/{}", - &base_url, - package_data.pkg_type, - package_data.name, - package_data.version, - package_data.hash, - )); - results.push(FoundResult { url, package_data }); - } - - // Check if we've fetched all packages based on totalSize. - if results.len() >= total_size { - break; - } - current_page += 1; - } - - tman_verbose_println!( - tman_config, - "Fetched {} packages for {}:{}", - results.len(), - pkg_identity.pkg_type, - pkg_identity.name, - ); - - Ok(results) + tman_verbose_println!( + &tman_config, + "Fetched {} packages for {}:{}", + results.len(), + pkg_identity.pkg_type, + pkg_identity.name, + ); + + Ok(results) + }) + }) + .await } pub async fn delete_package( @@ -356,70 +481,81 @@ pub async fn delete_package( base_url: &str, pkg_identity: &PkgIdentity, version: &Version, - hash: &String, + hash: &str, ) -> Result<()> { - let client = reqwest::Client::new(); - - // Ensure the base URL ends with a '/'. - let base_url = if base_url.ends_with('/') { - base_url.to_string() - } else { - format!("{}/", base_url) - }; - - let url = reqwest::Url::parse(&base_url).inspect_err(|&e| { - eprintln!("Failed to parse base URL: {}", e); - })?; - - let url = url - .join(&format!( - "{}/{}/{}/{}", - &pkg_identity.pkg_type.to_string(), - &pkg_identity.name, - version, - hash, - )) - .inspect_err(|&e| { - eprintln!("Failed to join URL path: {}", e); - })?; - - let mut headers = HeaderMap::new(); - - if let Some(admin_token) = &tman_config.admin_token { - let basic_token = format!("Basic {}", admin_token); - headers.insert( - AUTHORIZATION, - basic_token.parse().map_err(|e| { - eprintln!("Failed to parse authorization token: {}", e); - e - })?, - ); - } else { - tman_verbose_println!(tman_config, "Authorization token is missing"); - return Err(TmanError::Custom( - "Authorization token is missing".to_string(), - ) - .into()); - } + let max_retries = 3; + let retry_delay = Duration::from_millis(100); + + retry_async(tman_config, max_retries, retry_delay, || { + let base_url = base_url.to_string(); + let pkg_identity = pkg_identity.clone(); + let version = version.clone(); + let client = reqwest::Client::new(); + + Box::pin(async move { + // Ensure the base URL ends with a '/'. + let base_url = if base_url.ends_with('/') { + base_url + } else { + format!("{}/", base_url) + }; - // Sending the DELETE request. - let response = - client - .delete(url) - .headers(headers) - .send() - .await - .map_err(|e| { - eprintln!("Network request failed: {}", e); - e + let url = reqwest::Url::parse(&base_url).inspect_err(|&e| { + eprintln!("Failed to parse base URL: {}", e); })?; - if response.status().is_success() { - Ok(()) - } else { - Err( - TmanError::Custom(format!("HTTP error: {}", response.status())) - .into(), - ) - } + let url = url + .join(&format!( + "{}/{}/{}/{}", + &pkg_identity.pkg_type.to_string(), + &pkg_identity.name, + version, + hash, + )) + .inspect_err(|&e| { + eprintln!("Failed to join URL path: {}", e); + })?; + + let mut headers = HeaderMap::new(); + + if let Some(admin_token) = &tman_config.admin_token { + let basic_token = format!("Basic {}", admin_token); + headers.insert( + AUTHORIZATION, + basic_token.parse().map_err(|e| { + eprintln!("Failed to parse authorization token: {}", e); + e + })?, + ); + } else { + tman_verbose_println!( + &tman_config, + "Authorization token is missing" + ); + return Err(TmanError::Custom( + "Authorization token is missing".to_string(), + ) + .into()); + } + + // Sending the DELETE request. + let response = client.delete(url).headers(headers).send().await; + + match response { + Ok(resp) => { + if resp.status().is_success() { + Ok(()) + } else { + Err(TmanError::Custom(format!( + "HTTP error: {}", + resp.status() + )) + .into()) + } + } + Err(e) => Err(e.into()), + } + }) + }) + .await }