diff --git a/Cargo.lock b/Cargo.lock index cb55940..6937f5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,6 +97,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.1" @@ -216,19 +227,6 @@ dependencies = [ "futures-core", ] -[[package]] -name = "async-compat" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b48b4ff0c2026db683dea961cd8ea874737f56cffca86fa84415eaddc51c00d" -dependencies = [ - "futures-core", - "futures-io", - "once_cell", - "pin-project-lite", - "tokio", -] - [[package]] name = "async-executor" version = "1.5.0" @@ -238,7 +236,7 @@ dependencies = [ "async-lock", "async-task", "concurrent-queue", - "fastrand", + "fastrand 1.9.0", "futures-lite", "slab", ] @@ -258,7 +256,7 @@ dependencies = [ "parking", "polling", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", "windows-sys 0.42.0", ] @@ -354,11 +352,11 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backon" -version = "0.4.1" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1a6197b2120bb2185a267f6515038558b019e92b832bb0320e96d66268dcf9" +checksum = "d67782c3f868daa71d3533538e98a8e13713231969def7536e8039606fc46bf0" dependencies = [ - "fastrand", + "fastrand 2.1.0", "futures-core", "pin-project", "tokio", @@ -376,6 +374,12 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -403,6 +407,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + [[package]] name = "block-sys" version = "0.1.0-beta.1" @@ -456,9 +469,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "bytesize" @@ -510,13 +523,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" -version = "1.0.76" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" dependencies = [ "jobserver", + "libc", + "once_cell", ] [[package]] @@ -561,7 +585,6 @@ name = "cc_storage" version = "0.1.0" dependencies = [ "anyhow", - "async-trait", "bytes", "bytesize", "cc_core", @@ -622,16 +645,26 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.48.0", + "windows-targets 0.52.5", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", ] [[package]] @@ -913,9 +946,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "const-oid", @@ -1170,9 +1203,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -1262,6 +1295,12 @@ dependencies = [ "serde", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "error-code" version = "2.3.1" @@ -1287,6 +1326,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + [[package]] name = "flagset" version = "0.4.3" @@ -1332,9 +1377,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1356,9 +1401,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -1383,9 +1428,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -1393,7 +1438,7 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", @@ -1404,32 +1449,32 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 1.0.103", + "syn 2.0.11", ] [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1495,9 +1540,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -1657,9 +1702,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -1676,15 +1721,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" @@ -1738,9 +1777,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1755,15 +1794,15 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -1776,27 +1815,13 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.5.7", "tokio", "tower-service", "tracing", "want", ] -[[package]] -name = "hyper-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" -dependencies = [ - "futures-util", - "http", - "hyper", - "rustls", - "tokio", - "tokio-rustls", -] - [[package]] name = "iana-time-zone" version = "0.1.56" @@ -1823,9 +1848,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1855,12 +1880,12 @@ checksum = "df19da1e92fbfec043ca97d622955381b1f3ee72a180ec999912df31b1ccd951" [[package]] name = "indexmap" -version = "1.9.1" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown", ] [[package]] @@ -1869,6 +1894,16 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6c16b11a665b26aeeb9b1d7f954cdeb034be38dd00adab4f2ae921a8fee804" +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "block-padding", + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -1915,9 +1950,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -1930,22 +1965,23 @@ checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonwebtoken" -version = "8.2.0" +version = "9.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f4f04699947111ec1733e71778d763555737579e44b85844cae8e1940a1828" +checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", + "js-sys", "pem", - "ring", + "ring 0.17.8", "serde", "serde_json", "simple_asn1", @@ -1972,14 +2008,14 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] name = "libc" -version = "0.2.141" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -2364,18 +2400,17 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opendal" -version = "0.40.0" +version = "0.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddba7299bab261d3ae2f37617fb7f45b19ed872752bb4e22cf93a69d979366c5" +checksum = "4af824652d4d2ffabf606d337a071677ae621b05622adf35df9562f69d9b4498" dependencies = [ "anyhow", - "async-compat", "async-trait", "backon", "base64 0.21.0", @@ -2383,15 +2418,13 @@ dependencies = [ "chrono", "flagset", "futures", + "getrandom", "http", - "hyper", "log", "md-5", "once_cell", - "parking_lot", "percent-encoding", - "pin-project", - "quick-xml", + "quick-xml 0.30.0", "reqsign", "reqwest", "serde", @@ -2401,12 +2434,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - [[package]] name = "orbclient" version = "0.3.42" @@ -2421,12 +2448,12 @@ dependencies = [ [[package]] name = "ordered-multimap" -version = "0.6.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" +checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" dependencies = [ "dlv-list", - "hashbrown 0.13.2", + "hashbrown", ] [[package]] @@ -2501,13 +2528,24 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + [[package]] name = "pem" -version = "1.1.1" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.13.1", + "base64 0.22.1", + "serde", ] [[package]] @@ -2521,9 +2559,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pico-args" @@ -2553,9 +2591,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2574,6 +2612,21 @@ dependencies = [ "spki", ] +[[package]] +name = "pkcs5" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e847e2c91a18bfa887dd028ec33f2fe6f25db77db3619024764914affe8b69a6" +dependencies = [ + "aes", + "cbc", + "der", + "pbkdf2", + "scrypt", + "sha2", + "spki", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -2581,6 +2634,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", + "pkcs5", + "rand_core", "spki", ] @@ -2650,9 +2705,19 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.29.0" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ "memchr", "serde", @@ -2769,15 +2834,16 @@ dependencies = [ [[package]] name = "reqsign" -version = "0.14.1" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3228e570df74d69d3d3236a71371f1edd748a3e4eb728ea1f29d403bc10fc727" +checksum = "43e319d9de9ff4d941abf4ac718897118b0fe04577ea3f8e0f5788971784eef5" dependencies = [ "anyhow", "async-trait", "base64 0.21.0", "chrono", "form_urlencoded", + "getrandom", "hex", "hmac", "home", @@ -2786,7 +2852,7 @@ dependencies = [ "log", "once_cell", "percent-encoding", - "quick-xml", + "quick-xml 0.31.0", "rand", "reqwest", "rsa", @@ -2795,14 +2861,13 @@ dependencies = [ "serde_json", "sha1", "sha2", - "tokio", ] [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.0", "bytes", @@ -2813,7 +2878,6 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-rustls", "ipnet", "js-sys", "log", @@ -2821,14 +2885,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", - "rustls-native-certs", - "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", + "system-configuration", "tokio", - "tokio-rustls", "tokio-util", "tower-service", "url", @@ -2895,12 +2957,27 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + [[package]] name = "ron" version = "0.8.0" @@ -2937,6 +3014,7 @@ dependencies = [ "pkcs1", "pkcs8", "rand_core", + "sha2", "signature", "spki", "subtle", @@ -2945,9 +3023,9 @@ dependencies = [ [[package]] name = "rust-ini" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" +checksum = "3e0698206bcb8882bf2a9ecb4c1e7785db57ff052297085a6efd4fe42302068a" dependencies = [ "cfg-if", "ordered-multimap", @@ -2960,40 +3038,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" dependencies = [ "log", - "ring", + "ring 0.16.20", "rustls-webpki", "sct", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" -dependencies = [ - "base64 0.21.0", -] - [[package]] name = "rustls-webpki" version = "0.101.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -3003,21 +3060,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] -name = "same-file" -version = "1.0.6" +name = "salsa20" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" dependencies = [ - "winapi-util", + "cipher", ] [[package]] -name = "schannel" -version = "0.1.21" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "windows-sys 0.42.0", + "winapi-util", ] [[package]] @@ -3038,14 +3095,25 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "pbkdf2", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -3061,29 +3129,6 @@ dependencies = [ "tiny-skia", ] -[[package]] -name = "security-framework" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "serde" version = "1.0.147" @@ -3226,9 +3271,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smithay-client-toolkit" @@ -3269,12 +3314,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spin" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.2" @@ -3308,9 +3369,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svgtypes" @@ -3343,6 +3404,33 @@ dependencies = [ "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "system-deps" version = "6.0.3" @@ -3363,7 +3451,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", - "fastrand", + "fastrand 1.9.0", "libc", "redox_syscall 0.2.16", "remove_dir_all", @@ -3486,9 +3574,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" dependencies = [ "autocfg", "bytes", @@ -3496,44 +3584,33 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", "syn 2.0.11", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -3648,9 +3725,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3679,6 +3756,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "ureq" version = "2.8.0" @@ -3697,9 +3780,9 @@ dependencies = [ [[package]] name = "url" -version = "2.3.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -3826,9 +3909,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.33" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -3867,9 +3950,9 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-streams" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", @@ -3965,9 +4048,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -4150,6 +4233,15 @@ dependencies = [ "windows-targets 0.48.0", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-targets" version = "0.42.1" @@ -4180,6 +4272,22 @@ dependencies = [ "windows_x86_64_msvc 0.48.0", ] +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.1" @@ -4192,6 +4300,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + [[package]] name = "windows_aarch64_msvc" version = "0.37.0" @@ -4210,6 +4324,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + [[package]] name = "windows_i686_gnu" version = "0.37.0" @@ -4228,6 +4348,18 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + [[package]] name = "windows_i686_msvc" version = "0.37.0" @@ -4246,6 +4378,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + [[package]] name = "windows_x86_64_gnu" version = "0.37.0" @@ -4264,6 +4402,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.1" @@ -4276,6 +4420,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + [[package]] name = "windows_x86_64_msvc" version = "0.37.0" @@ -4294,6 +4444,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + [[package]] name = "winit" version = "0.28.1" @@ -4331,11 +4487,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -4456,9 +4613,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.7" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" [[package]] name = "zvariant" diff --git a/Cargo.toml b/Cargo.toml index 8c9090c..f4d7975 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,12 @@ description = "A simple cross-platform desktop application for S3-Compatible Obj [package.metadata.bundle] name = "Caricare" identifier = "com.fireyy.caricare" -icon = ["icons/Icon.icns", "icons/Icon.iconset/icon-256.png", "icons/Icon.iconset/icon-32.png", "icons/Icon.iconset/icon-16.png"] +icon = [ + "icons/Icon.icns", + "icons/Icon.iconset/icon-256.png", + "icons/Icon.iconset/icon-32.png", + "icons/Icon.iconset/icon-16.png", +] version = "1.0.0" copyright = "Copyright (c) Fireyy (2023). All rights reserved." category = "Developer Tool" @@ -15,17 +20,7 @@ short_description = "A simple cross-platform desktop application for S3-Compatib osx_minimum_system_version = "10.12" [features] -default = ["services-s3-compatible"] -# Enable Amazon Simple Storage Service support -services-s3 = ["cc_storage/services-s3"] -# Enable Aliyun Object Storage Service support -services-oss = ["cc_storage/services-oss"] -# Enable Google Cloud Storage support -services-gcs = ["cc_storage/services-gcs"] -# Enable Azure Blob Storage support -services-azblob = ["cc_storage/services-azblob"] -# Enable S3-Compatible Object Storage support -services-s3-compatible = ["cc_storage/services-s3-compatible"] +default = [] # Enable CJK char support lang-cjk = ["cc_ui/lang-cjk"] @@ -38,7 +33,12 @@ serde = { workspace = true } egui = { workspace = true } cc_files = { workspace = true } egui_extras = { workspace = true } -image = { version = "0.24.6", default-features = false, features = ["png", "jpeg", "gif", "webp"] } +image = { version = "0.24.6", default-features = false, features = [ + "png", + "jpeg", + "gif", + "webp", +] } rfd = "0.10" egui-notify = "0.6" tracing = { workspace = true } @@ -48,9 +48,7 @@ once_cell = { workspace = true } [workspace] resolver = "2" -members = [ - "crates/*", -] +members = ["crates/*"] [workspace.package] authors = ["fireyy zhu "] @@ -88,4 +86,4 @@ strip = true opt-level = "z" lto = true codegen-units = 1 -panic = "abort" \ No newline at end of file +panic = "abort" diff --git a/crates/cc_storage/Cargo.toml b/crates/cc_storage/Cargo.toml index 4262d41..5165e7a 100644 --- a/crates/cc_storage/Cargo.toml +++ b/crates/cc_storage/Cargo.toml @@ -5,31 +5,22 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[features] -default = ["services-s3-compatible"] -# Enable Amazon Simple Storage Service support -services-s3 = ["opendal/services-s3"] -# Enable Aliyun Object Storage Service support -services-oss = ["opendal/services-oss"] -# Enable Google Cloud Storage support -services-gcs = ["opendal/services-gcs"] -# Enable Azure Blob Storage support -services-azblob = ["opendal/services-azblob"] -# Enable S3-Compatible Object Storage support -services-s3-compatible = ["services-s3"] - [dependencies] thiserror = "1.0" anyhow = "1.0" tracing = { workspace = true } bytesize = "1.1.0" chrono = "0.4.24" -opendal = "0.40.0" +opendal = { version = "0.44.2", default-features = false, features = [ + "services-azblob", + "services-gcs", + "services-oss", + "services-s3", +] } http = "0.2.9" futures = "0.3" bytes = "1.3" tokio = { version = "^1.0", features = ["fs", "io-util", "sync"] } pin-project = "1" crossbeam-channel = { workspace = true } -async-trait = "0.1.68" -cc_core = { workspace = true } \ No newline at end of file +cc_core = { workspace = true } diff --git a/crates/cc_storage/src/client.rs b/crates/cc_storage/src/client.rs index ff5b22e..4149f36 100644 --- a/crates/cc_storage/src/client.rs +++ b/crates/cc_storage/src/client.rs @@ -1,22 +1,22 @@ -use std::io::Write; use std::path::PathBuf; use std::sync::Arc; use crate::config::ClientConfig; -use crate::partial_file::PartialFile; use crate::transfer::{TransferProgressInfo, TransferSender, TransferType}; -use crate::types::{Bucket, ListObjects, Object, Params}; +use crate::types::{Bucket, ListObjects, ListObjectsV2Params, Object, Params}; use crate::util::get_name; use crate::Result; -use anyhow::Context; use cc_core::ServiceType; +use futures::StreamExt; use crate::services; -use crate::stream::{ - AsyncReadProgressExt, BoxedStreamingUploader, StreamingUploader, TrackableBodyStream, -}; -use futures::{AsyncReadExt, TryStreamExt}; use opendal::{Metadata, Metakey, Operator}; +use tokio::{ + fs, + io::{self, AsyncWriteExt as _}, +}; + +const DEFAULT_BUF_SIZE: usize = 8 * 1024 * 1024; #[derive(Clone)] pub struct Client { @@ -82,29 +82,29 @@ impl Client { tracing::debug!("Response header: {:?}", meta); - Ok((meta, result)) + Ok((meta, result.to_vec())) } pub async fn get_object(&self, object: impl AsRef) -> Result<(String, Vec)> { let object = object.as_ref(); let result = self.operator.read(object).await?; - Ok((object.to_string(), result)) + Ok((object.to_string(), result.to_vec())) } pub async fn get_object_range(&self, object: impl AsRef) -> Result<(String, Vec)> { let object = object.as_ref(); let result = self.operator.read_with(object).range(..128).await?; - Ok((object.to_string(), result)) + Ok((object.to_string(), result.to_vec())) } pub async fn delete_object(&self, object: impl AsRef) -> Result { let object = object.as_ref(); self.operator.delete(object).await?; - let result = self.operator.is_exist(object).await?; + // let result = self.operator.is_exist(object).await?; - Ok(result) + Ok(true) } pub async fn delete_multi_object(self, obj: Vec) -> Result { @@ -120,23 +120,31 @@ impl Client { Ok(true) } - pub async fn list_v2(&self, query: Option) -> Result { + pub async fn list_v2(&self, query: ListObjectsV2Params) -> Result { tracing::debug!("List object: {:?}", query); - let path = query.map_or("".into(), |x| format!("{x}/")); + // let path = query.prefix.map_or("".into(), |x| format!("{x}/")); + let mut path = query.prefix; + if !path.is_empty() && !path.ends_with('/') { + path.push('/'); + } //TODO 分页功能 let mut stream = self .operator .lister_with(&path) + .start_after(&query.start_after) .metakey(Metakey::Mode | Metakey::ContentLength | Metakey::LastModified) - .await?; + .await? + .chunks(100); - let mut list_objects = ListObjects::default(); - let mut common_prefixes = Vec::new(); - let mut objects = Vec::new(); + let (mut common_prefixes, mut objects) = (vec![], vec![]); - while let Some(entry) = stream.try_next().await? { - let meta = entry.metadata(); + let page = stream.next().await.unwrap_or_default(); + let is_truncated = page.len() >= 100; + + for v in page { + let entry = v?; + let meta = entry.metadata(); if meta.is_dir() { common_prefixes.push(Object::new_folder(entry.path())); } else { @@ -148,6 +156,13 @@ impl Client { } } + let mut list_objects = ListObjects::default(); + list_objects.set_start_after(if objects.is_empty() { + common_prefixes.last().unwrap().key().to_owned() + } else { + objects.last().unwrap().key().to_owned() + }); + list_objects.set_is_truncated(is_truncated); list_objects.set_common_prefixes(common_prefixes); list_objects.set_objects(objects); @@ -184,67 +199,36 @@ impl Client { Ok((src.to_string(), is_move)) } - fn streaming_upload(&self, path: &str) -> Result { - Ok(Box::new(StreamingUploader::new( - self.operator.clone(), - path.to_string(), - ))) - } - - async fn streaming_read( - &self, - path: &str, - start_pos: Option, - transfer: TransferSender, - ) -> Result> { - let reader = match start_pos { - Some(start_position) => { - self.operator - .reader_with(path) - .range(start_position as u64..) - .await? - } - None => self.operator.reader(path).await?, - }; - - let size = self.meta_data(path).await?.content_length(); - let mut body = Vec::new(); - - let mut stream = reader.into_async_read().report_progress(|bytes_read| { - transfer - .send(TransferType::Download( - path.to_string(), - TransferProgressInfo { - total_bytes: size, - transferred_bytes: bytes_read as u64, - }, - )) - .unwrap(); - }); - - stream - .read_to_end(&mut body) - .await - .context("failed to read object content into buffer")?; - - Ok(body) - } - pub async fn download_file( &self, obj: &str, target: PathBuf, transfer: TransferSender, ) -> Result<()> { - let mut new_file = PartialFile::create(&target) - .with_context(|| format!("create `{}`", target.display()))?; - - let content = self.streaming_read(obj, None, transfer).await?; - - new_file - .write_all(&content) - .context("write content of file")?; - new_file.finish().context("finish writing to new file")?; + let remote_op = self.operator.clone(); + let progress_tx = transfer.clone(); + let oid = obj.to_string(); + let total_bytes = self.meta_data(obj).await?.content_length(); + + tokio::spawn(async move { + let _: Result> = async { + fs::create_dir_all(target.parent().unwrap()).await?; + let mut reader = remote_op.reader_with(&oid).buffer(DEFAULT_BUF_SIZE).await?; + let mut writer = io::BufWriter::new(fs::File::create(&target).await?); + copy_with_progress( + "download", + &progress_tx, + &oid, + total_bytes, + &mut reader, + &mut writer, + ) + .await?; + writer.shutdown().await?; + Ok(Some(target.to_string_lossy().into())) + } + .await; + }); Ok(()) } @@ -252,34 +236,29 @@ impl Client { pub async fn put(&self, path: PathBuf, dest: &str, transfer: &TransferSender) -> Result<()> { let name = get_name(&path); let key = format!("{dest}{name}"); - - let mut body = TrackableBodyStream::try_from(path) - .map_err(|e| { - panic!("Could not open sample file: {e}"); - }) - .unwrap(); + let remote_op = self.operator.clone(); let progress_tx = transfer.clone(); + let total_bytes = fs::metadata(&path).await?.len(); + + tokio::spawn(async move { + let _: Result> = async { + let mut reader = io::BufReader::new(fs::File::open(path).await?); + let mut writer = remote_op.writer_with(&key).buffer(DEFAULT_BUF_SIZE).await?; + copy_with_progress( + "upload", + &progress_tx, + &key, + total_bytes, + &mut reader, + &mut writer, + ) + .await?; + writer.close().await?; + Ok(None) + } + .await; + }); - body.set_callback( - &key, - move |key: &str, tot_size: u64, sent: u64, _cur_buf: u64| { - progress_tx - .send(TransferType::Upload( - key.to_string(), - TransferProgressInfo { - total_bytes: tot_size, - transferred_bytes: sent, - }, - )) - .unwrap(); - }, - ); - - let mut uploader = self.streaming_upload(&key)?; - while let Ok(Some(bytes)) = body.try_next().await { - uploader.write_bytes(bytes).await?; - } - uploader.finish().await?; // TODO: check if put success Ok(()) @@ -352,3 +331,53 @@ impl ClientBuilder { Client::new(self.config) } } + +async fn copy_with_progress( + tp: &str, + progress_sender: &TransferSender, + key: &str, + total_bytes: u64, + mut reader: R, + mut writer: W, +) -> io::Result +where + R: io::AsyncReadExt + Unpin, + W: io::AsyncWriteExt + Unpin, +{ + let mut bytes_so_far: usize = 0; + let mut buf = vec![0; DEFAULT_BUF_SIZE]; + + loop { + let bytes_since_last = reader.read(&mut buf).await?; + if bytes_since_last == 0 { + break; + } + writer.write_all(&buf[..bytes_since_last]).await?; + bytes_so_far += bytes_since_last; + let msg = if tp == "download" { + TransferType::Download( + key.to_string(), + TransferProgressInfo { + total_bytes: total_bytes as usize, + transferred_bytes: bytes_so_far, + }, + ) + } else { + TransferType::Upload( + key.to_string(), + TransferProgressInfo { + total_bytes: total_bytes as usize, + transferred_bytes: bytes_so_far, + }, + ) + }; + send_response(progress_sender, msg).await; + } + + Ok(bytes_so_far) +} + +async fn send_response(sender: &TransferSender, msg: TransferType) { + // tracing::debug!("response: {}", &msg); + sender.send(msg).unwrap(); +} diff --git a/crates/cc_storage/src/custom_layer.rs b/crates/cc_storage/src/custom_layer.rs deleted file mode 100644 index e487ca8..0000000 --- a/crates/cc_storage/src/custom_layer.rs +++ /dev/null @@ -1,57 +0,0 @@ -use async_trait::async_trait; -use opendal::raw::*; -use opendal::*; - -#[derive(Debug)] -pub struct CustomAccessor { - inner: A, -} - -#[async_trait] -impl LayeredAccessor for CustomAccessor { - type Inner = A; - type Reader = A::Reader; - type BlockingReader = A::BlockingReader; - type Writer = A::Writer; - type BlockingWriter = A::BlockingWriter; - type Pager = A::Pager; - type BlockingPager = A::BlockingPager; - - fn inner(&self) -> &Self::Inner { - &self.inner - } - - async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> { - self.inner.read(path, args).await - } - - fn blocking_read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::BlockingReader)> { - self.inner.blocking_read(path, args) - } - - async fn write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::Writer)> { - self.inner.write(path, args).await - } - - fn blocking_write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::BlockingWriter)> { - self.inner.blocking_write(path, args) - } - - async fn list(&self, path: &str, args: OpList) -> Result<(RpList, Self::Pager)> { - self.inner.list(path, args).await - } - - fn blocking_list(&self, path: &str, args: OpList) -> Result<(RpList, Self::BlockingPager)> { - self.inner.blocking_list(path, args) - } -} - -pub struct CustomLayer; - -impl Layer for CustomLayer { - type LayeredAccessor = CustomAccessor; - - fn layer(&self, inner: A) -> Self::LayeredAccessor { - CustomAccessor { inner } - } -} diff --git a/crates/cc_storage/src/error.rs b/crates/cc_storage/src/error.rs index 88012ed..df9b33f 100644 --- a/crates/cc_storage/src/error.rs +++ b/crates/cc_storage/src/error.rs @@ -8,5 +8,3 @@ pub enum OSSError { #[error("{0}")] WithDescription(String), } - -pub type ObjectResult = std::result::Result; diff --git a/crates/cc_storage/src/lib.rs b/crates/cc_storage/src/lib.rs index 63bd7d0..ba6ac21 100644 --- a/crates/cc_storage/src/lib.rs +++ b/crates/cc_storage/src/lib.rs @@ -2,11 +2,10 @@ pub type Result = anyhow::Result; mod client; mod config; -mod custom_layer; mod error; -mod partial_file; +// mod partial_file; mod services; -mod stream; +// mod stream; mod transfer; mod types; pub mod util; @@ -14,9 +13,8 @@ mod version; pub use cc_core::ServiceType; pub use client::Client; -pub use custom_layer::CustomLayer; pub use error::OSSError; pub use opendal::{Lister, Metadata}; pub use transfer::TransferManager; -pub use types::{Bucket, Headers, ListObjects, Object, ObjectType, Params}; +pub use types::{Bucket, Headers, ListObjects, ListObjectsV2Params, Object, ObjectType, Params}; pub use version::VERSION; diff --git a/crates/cc_storage/src/partial_file.rs b/crates/cc_storage/src/partial_file.rs deleted file mode 100644 index e46b87b..0000000 --- a/crates/cc_storage/src/partial_file.rs +++ /dev/null @@ -1,120 +0,0 @@ -use crate::Result; -use anyhow::Context; -use std::{ - ffi::OsString, - fs::{self, File}, - io::{BufWriter, Write}, - path::{Path, PathBuf}, - time::SystemTime, -}; - -/// Small helper struct to make writing files a bit safer by first writing to a -/// hidden file and once finished renaming it to the requested name. -#[derive(Debug)] -pub struct PartialFile { - target_path: PathBuf, - partial_path: PathBuf, - partial_file: BufWriter, - finished: bool, -} - -impl PartialFile { - pub fn create(target_path: impl Into) -> Result { - let target_path: PathBuf = target_path.into(); - let partial_path = generate_partial_file_name(&target_path) - .context("could not generate name for partial/temporary file")?; - let partial_file = File::create(&partial_path).with_context(|| { - format!( - "could not create partial/temp file `{}`", - partial_path.display() - ) - })?; - let partial_file = BufWriter::new(partial_file); - - Ok(PartialFile { - target_path, - partial_path, - partial_file, - finished: false, - }) - } - - pub fn finish(mut self) -> Result { - self.partial_file.flush().with_context(|| { - format!( - "failed to flush outstanding writes to `{}`", - self.partial_path.display() - ) - })?; - fs::rename(&self.partial_path, &self.target_path).with_context(|| { - format!( - "cannot finish partial file `{}`, renaming it to `{}` failed", - self.partial_path.display(), - self.target_path.display() - ) - })?; - self.finished = true; - File::open(&self.target_path) - .with_context(|| format!("cannot open finished file `{}`", self.target_path.display())) - } -} - -impl Write for PartialFile { - fn write(&mut self, buf: &[u8]) -> std::io::Result { - self.partial_file.write(buf) - } - - fn flush(&mut self) -> std::io::Result<()> { - self.partial_file.flush() - } - - fn write_vectored(&mut self, bufs: &[std::io::IoSlice<'_>]) -> std::io::Result { - self.partial_file.write_vectored(bufs) - } - - fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { - self.partial_file.write_all(buf) - } -} - -impl Drop for PartialFile { - fn drop(&mut self) { - if self.finished { - return; - } - - tracing::info!("Deleting partial file `{}`.", self.partial_path.display()); - tracing::debug!( - "Partial file `{}` was meant to be moved to `{}` once finished", - self.partial_path.display(), - self.target_path.display() - ); - if let Err(e) = fs::remove_file(&self.partial_path) { - tracing::warn!( - "Could not delete partial file `{}`: {}", - self.partial_path.display(), - e - ) - } - } -} - -fn generate_partial_file_name(path: &Path) -> Result { - let target_file_name = path - .file_name() - .with_context(|| format!("cannot get file name from path `{}`", path.display()))?; - let temp_prefix = { - let timestamp = SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .context("cannot get timestamp")?; - format!("artefacta-temp-{}", timestamp.as_secs()) - }; - let new_file_name = { - let mut res = OsString::from("._"); - res.push(&temp_prefix); - res.push(target_file_name); - res.push(".part"); - res - }; - Ok(path.with_file_name(new_file_name)) -} diff --git a/crates/cc_storage/src/services/azblob.rs b/crates/cc_storage/src/services/azblob.rs index d8fe72a..1503493 100644 --- a/crates/cc_storage/src/services/azblob.rs +++ b/crates/cc_storage/src/services/azblob.rs @@ -1,5 +1,5 @@ use crate::config::ClientConfig; -use crate::{CustomLayer, Result}; +use crate::Result; use opendal::services::Azblob; use opendal::Operator; use std::sync::Arc; @@ -10,7 +10,7 @@ pub(crate) fn create(config: &Arc) -> Result { builder.endpoint(&config.endpoint); builder.account_name(&config.access_key_id); builder.account_key(&config.access_key_secret); - let operator: Operator = Operator::new(builder)?.layer(CustomLayer).finish(); + let operator: Operator = Operator::new(builder)?.finish(); Ok(operator) } diff --git a/crates/cc_storage/src/services/gcs.rs b/crates/cc_storage/src/services/gcs.rs index f6167b1..0f25eb3 100644 --- a/crates/cc_storage/src/services/gcs.rs +++ b/crates/cc_storage/src/services/gcs.rs @@ -1,5 +1,5 @@ use crate::config::ClientConfig; -use crate::{CustomLayer, Result}; +use crate::Result; use opendal::services::Gcs; use opendal::Operator; use std::sync::Arc; @@ -9,7 +9,7 @@ pub(crate) fn create(config: &Arc) -> Result { builder.bucket(&config.bucket); builder.endpoint(&config.endpoint); builder.credential(&config.access_key_secret); - let operator: Operator = Operator::new(builder)?.layer(CustomLayer).finish(); + let operator: Operator = Operator::new(builder)?.finish(); Ok(operator) } diff --git a/crates/cc_storage/src/services/oss.rs b/crates/cc_storage/src/services/oss.rs index af6e4f2..f4d4fcc 100644 --- a/crates/cc_storage/src/services/oss.rs +++ b/crates/cc_storage/src/services/oss.rs @@ -1,5 +1,5 @@ use crate::config::ClientConfig; -use crate::{CustomLayer, Result}; +use crate::Result; use opendal::services::Oss; use opendal::Operator; use std::sync::Arc; @@ -10,7 +10,7 @@ pub(crate) fn create(config: &Arc) -> Result { builder.endpoint(&config.endpoint); builder.access_key_id(&config.access_key_id); builder.access_key_secret(&config.access_key_secret); - let operator: Operator = Operator::new(builder)?.layer(CustomLayer).finish(); + let operator: Operator = Operator::new(builder)?.finish(); Ok(operator) } diff --git a/crates/cc_storage/src/services/s3.rs b/crates/cc_storage/src/services/s3.rs index 24cbef1..1b96a3f 100644 --- a/crates/cc_storage/src/services/s3.rs +++ b/crates/cc_storage/src/services/s3.rs @@ -1,5 +1,5 @@ use crate::config::ClientConfig; -use crate::{CustomLayer, Result}; +use crate::Result; use opendal::services::S3; use opendal::Operator; use std::sync::Arc; @@ -10,7 +10,7 @@ pub(crate) fn create(config: &Arc) -> Result { builder.endpoint(&config.endpoint); builder.access_key_id(&config.access_key_id); builder.secret_access_key(&config.access_key_secret); - let operator: Operator = Operator::new(builder)?.layer(CustomLayer).finish(); + let operator: Operator = Operator::new(builder)?.finish(); Ok(operator) } diff --git a/crates/cc_storage/src/services/s3_compatible.rs b/crates/cc_storage/src/services/s3_compatible.rs index 4a2d2f7..7fdffea 100644 --- a/crates/cc_storage/src/services/s3_compatible.rs +++ b/crates/cc_storage/src/services/s3_compatible.rs @@ -1,5 +1,5 @@ use crate::config::ClientConfig; -use crate::{CustomLayer, Result}; +use crate::Result; use opendal::services::S3; use opendal::Operator; use std::sync::Arc; @@ -17,7 +17,7 @@ pub(crate) fn create(config: &Arc) -> Result { if config.endpoint.contains("aliyuncs.com") { builder.enable_virtual_host_style(); } - let operator: Operator = Operator::new(builder)?.layer(CustomLayer).finish(); + let operator: Operator = Operator::new(builder)?.finish(); Ok(operator) } diff --git a/crates/cc_storage/src/stream.rs b/crates/cc_storage/src/stream.rs deleted file mode 100644 index c073d5a..0000000 --- a/crates/cc_storage/src/stream.rs +++ /dev/null @@ -1,216 +0,0 @@ -use core::{ - pin::Pin, - task::{Context, Poll}, -}; -use futures::io::{AsyncRead as FAsyncRead, IoSliceMut}; -use pin_project::pin_project; -use std::path::PathBuf; -use std::{fmt, io}; - -use futures::{Future, Stream}; -use tokio::{fs::File, io::AsyncReadExt}; - -use crate::error::ObjectResult; -use bytes::{BufMut, Bytes, BytesMut}; -use opendal::Operator; - -const DEFAULT_BUFFER_SIZE: usize = 2048; - -/// The callback function triggered every time a chunck of the source file is read -/// in the buffer. -/// -/// # Arguments -/// * `u64`: The total length of the buffer (or size of the file if created from a `PathBuf`) -/// * `u64`: The total number of bytes read so far -/// * `u64`: The number of bytes read in the current chunck -type CallbackFn = dyn FnMut(&str, u64, u64, u64) + Sync + Send + 'static; - -/// A `futures::Stream` implementation that can be used to track uploads -/// ``` -pub struct TrackableBodyStream { - input: I, - file_size: u64, - cur_read: u64, - key: String, - callback: Option>, - buffer_size: usize, -} - -impl TryFrom for TrackableBodyStream { - type Error = std::io::Error; - - fn try_from(value: PathBuf) -> Result { - let file_size = std::fs::metadata(value.clone())?.len(); - let file = futures::executor::block_on(tokio::fs::File::open(value))?; - Ok(Self { - input: file, - file_size, - cur_read: 0, - key: String::new(), - callback: None, - buffer_size: DEFAULT_BUFFER_SIZE, - }) - } -} - -impl TrackableBodyStream { - /// Sets the callback method - pub fn set_callback( - &mut self, - key: &str, - callback: impl FnMut(&str, u64, u64, u64) + Sync + Send + 'static, - ) { - self.key = key.to_string(); - self.callback = Some(Box::new(callback)); - } -} - -impl Stream for TrackableBodyStream { - type Item = Result>; - - fn poll_next( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> Poll> { - let mut_self = self.get_mut(); - let mut buf = Vec::with_capacity(mut_self.buffer_size); - - match Future::poll(Box::pin(mut_self.input.read_buf(&mut buf)).as_mut(), cx) { - Poll::Ready(res) => { - if res.is_err() { - return Poll::Ready(Some(Err(Box::new(res.err().unwrap())))); - } - let read_op = res.unwrap(); - if read_op == 0 { - return Poll::Ready(None); - } - mut_self.cur_read += read_op as u64; - //buf.resize(read_op, 0u8); - if mut_self.callback.is_some() { - mut_self.callback.as_mut().unwrap()( - mut_self.key.as_str(), - mut_self.file_size, - mut_self.cur_read, - read_op as u64, - ); - } - Poll::Ready(Some(Ok(Bytes::from(Vec::from(&buf[0..read_op]))))) - } - Poll::Pending => Poll::Pending, - } - } - - fn size_hint(&self) -> (usize, Option) { - ( - (self.file_size - self.cur_read) as usize, - Some(self.file_size as usize), - ) - } -} - -pub type BoxedStreamingUploader = Box; - -/// Store multiple parts in a map, and concatenate them on finish. -pub struct StreamingUploader { - op: Operator, - path: String, - buffer: BytesMut, -} -impl StreamingUploader { - pub fn new(op: Operator, path: String) -> Self { - Self { - op, - path, - buffer: BytesMut::new(), - } - } - - pub async fn write_bytes(&mut self, data: Bytes) -> ObjectResult<()> { - self.buffer.put(data); - Ok(()) - } - - pub async fn finish(self: Box) -> ObjectResult<()> { - self.op.write(&self.path, self.buffer).await?; - - Ok(()) - } -} - -/// Reader for the `report_progress` method. -#[pin_project] -#[must_use = "streams do nothing unless polled"] -pub struct StreamDownloader { - #[pin] - inner: St, - callback: F, - bytes_read: usize, -} - -impl fmt::Debug for StreamDownloader -where - St: fmt::Debug, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("StreamDownloader") - .field("stream", &self.inner) - .finish() - } -} - -pub trait AsyncReadProgressExt { - fn report_progress(self, callback: F) -> StreamDownloader - where - Self: Sized, - F: FnMut(usize), - { - let bytes_read = 0; - StreamDownloader { - inner: self, - callback, - bytes_read, - } - } -} - -impl AsyncReadProgressExt for R {} - -impl FAsyncRead for StreamDownloader -where - St: FAsyncRead, - F: FnMut(usize), -{ - fn poll_read( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { - let this = self.project(); - match this.inner.poll_read(cx, buf) { - Poll::Pending => Poll::Pending, - Poll::Ready(Err(e)) => Poll::Ready(Err(e)), - Poll::Ready(Ok(bytes_read)) => { - *this.bytes_read += bytes_read; - (this.callback)(*this.bytes_read); - Poll::Ready(Ok(bytes_read)) - } - } - } - - fn poll_read_vectored( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - bufs: &mut [IoSliceMut<'_>], - ) -> Poll> { - let this = self.project(); - match this.inner.poll_read_vectored(cx, bufs) { - Poll::Pending => Poll::Pending, - Poll::Ready(Err(e)) => Poll::Ready(Err(e)), - Poll::Ready(Ok(bytes_read)) => { - *this.bytes_read += bytes_read; - (this.callback)(*this.bytes_read); - Poll::Ready(Ok(bytes_read)) - } - } - } -} diff --git a/crates/cc_storage/src/transfer.rs b/crates/cc_storage/src/transfer.rs index c6d9d54..f7da80e 100644 --- a/crates/cc_storage/src/transfer.rs +++ b/crates/cc_storage/src/transfer.rs @@ -5,8 +5,8 @@ pub type TransferSender = crossbeam_channel::Sender; #[derive(Clone, Default, Debug)] pub struct TransferProgressInfo { - pub total_bytes: u64, - pub transferred_bytes: u64, + pub total_bytes: usize, + pub transferred_bytes: usize, } impl TransferProgressInfo { @@ -92,7 +92,11 @@ impl TransferManager { } fn update_download(&mut self, key: String, item: TransferProgressInfo) { - // tracing::debug!("Download `{key}`… {}/{}", item.current, item.total); + tracing::debug!( + "Download `{key}`… {}/{}", + item.transferred_bytes, + item.total_bytes + ); if item.transferred_bytes == item.total_bytes { tracing::debug!("Download Done!"); } @@ -100,7 +104,11 @@ impl TransferManager { } fn update_upload(&mut self, key: String, item: TransferProgressInfo) { - // tracing::debug!("Upload `{key}`… {}/{}", item.current, item.total); + tracing::debug!( + "Upload `{key}`… {}/{}", + item.transferred_bytes, + item.total_bytes + ); if item.transferred_bytes == item.total_bytes { tracing::debug!("Upload Done!"); } diff --git a/crates/cc_storage/src/types.rs b/crates/cc_storage/src/types.rs index cc5ee82..d8fb8b0 100644 --- a/crates/cc_storage/src/types.rs +++ b/crates/cc_storage/src/types.rs @@ -56,6 +56,10 @@ impl ListObjects { &self.start_after } + pub fn set_start_after(&mut self, start_after: String) { + self.start_after = start_after; + } + pub fn max_keys(&self) -> &str { &self.max_keys } @@ -64,6 +68,10 @@ impl ListObjects { self.is_truncated } + pub fn set_is_truncated(&mut self, is_truncated: bool) { + self.is_truncated = is_truncated; + } + pub fn next_continuation_token(&self) -> &Option { &self.next_continuation_token } @@ -240,3 +248,20 @@ impl Bucket { } } } + +#[derive(Default, Debug, Clone)] +pub struct ListObjectsV2Params { + pub prefix: String, + pub start_after: String, + pub is_truncated: bool, +} + +impl ListObjectsV2Params { + pub fn new(prefix: String, start_after: String, is_truncated: bool) -> Self { + ListObjectsV2Params { + prefix, + start_after, + is_truncated, + } + } +} diff --git a/src/pages/main.rs b/src/pages/main.rs index cdf12f1..9b40fad 100644 --- a/src/pages/main.rs +++ b/src/pages/main.rs @@ -102,7 +102,7 @@ pub fn main_page(ctx: &egui::Context, state: &mut State, frame: &mut eframe::Fra // max_scroll, // ); - if state.next_query.is_some() + if state.next_query.is_truncated && current_scroll + 20.0 >= max_scroll && !state.loading_more { diff --git a/src/state.rs b/src/state.rs index 9200d91..14f1a8c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -10,7 +10,8 @@ use cc_files::{Cache as ImageCache, FileType}; use cc_storage::util::get_name_form_path; use cc_storage::{ - Bucket, Client, ListObjects, Metadata, Object, Params, Result as ClientResult, TransferManager, + Bucket, Client, ListObjects, ListObjectsV2Params, Metadata, Object, Params, + Result as ClientResult, TransferManager, }; use std::{path::PathBuf, vec}; @@ -74,7 +75,7 @@ pub struct State { pub setting: Setting, pub file_view: FileView, pub loading_more: bool, - pub next_query: Option, + pub next_query: ListObjectsV2Params, pub scroll_top: bool, pub file_cache: ImageCache, pub logs: Vec, @@ -99,10 +100,7 @@ pub struct State { impl State { pub fn new(ctx: &egui::Context) -> Self { - let session = match store::get_latest_session() { - Some(session) => session, - None => Session::default(), - }; + let session = store::get_latest_session().unwrap_or_default(); let mut client = None; let mut bucket = None; @@ -150,7 +148,7 @@ impl State { err: None, file_view: FileView::new(), loading_more: false, - next_query: None, + next_query: ListObjectsV2Params::default(), scroll_top: false, file_cache: images, logs: vec![], @@ -172,7 +170,7 @@ impl State { transfer_manager: TransferManager::new(), }; - this.next_query = Some(this.build_query(None)); + // this.next_query = Some(this.build_query(None)); this.sessions = this.load_all_session(); if is_need_init { @@ -195,11 +193,14 @@ impl State { } Update::List(result) => match result { Ok(str) => { - if let Some(token) = str.next_continuation_token() { - self.next_query = Some(self.build_query(Some(token.clone()))); - } else { - self.next_query = None; - } + // if let Some(token) = str.next_continuation_token() { + // self.next_query = Some(self.build_query(Some(token.clone()))); + // } else { + // self.next_query = None; + // } + self.next_query.start_after = str.start_after().to_string(); + self.next_query.prefix = str.prefix().to_string(); + self.next_query.is_truncated = str.is_truncated(); self.set_list(str); self.loading_more = false; self.status = Status::Idle(Route::List); @@ -231,6 +232,7 @@ impl State { Update::Deleted(result) => match result { Ok(success) => { if success { + tracing::debug!("Delete success."); self.refresh(); } else { self.toasts.error("Delete failed."); @@ -497,19 +499,17 @@ impl State { } pub fn get_list(&mut self) { - if let Some(_query) = &self.next_query { - if !self.loading_more { - self.status = Status::Busy(Route::List); - } + if !self.loading_more { + self.status = Status::Busy(Route::List); + } - let query = self.current_path.clone(); + let query = self.next_query.clone(); - spawn_evs!(self, |evs, client, ctx| { - let res = client.list_v2(Some(query)).await; - evs.send(Update::List(res)).unwrap(); - ctx.request_repaint(); - }); - } + spawn_evs!(self, |evs, client, ctx| { + let res = client.list_v2(query).await; + evs.send(Update::List(res)).unwrap(); + ctx.request_repaint(); + }); } pub fn set_list(&mut self, obj: ListObjects) { @@ -525,7 +525,7 @@ impl State { pub fn load_more(&mut self) { tracing::debug!("load more!"); - if self.next_query.is_some() { + if self.next_query.is_truncated { self.get_list(); } else { //no more @@ -537,7 +537,7 @@ impl State { self.scroll_top = true; let current_path = self.navigator.location(); self.current_path = current_path; - self.next_query = Some(self.build_query(None)); + self.next_query = ListObjectsV2Params::default(); self.list = vec![]; self.get_list(); } @@ -546,7 +546,7 @@ impl State { self.refresh(); } - fn build_query(&self, next_token: Option) -> Params { + fn _build_query(&self, next_token: Option) -> Params { let mut path = self.current_path.clone(); if !path.ends_with('/') && !path.is_empty() { path.push('/'); @@ -576,7 +576,7 @@ impl State { store::put_session(&self.session)?; let current_path = "".to_string(); - self.current_path = current_path.clone(); + self.current_path.clone_from(¤t_path); self.navigator.push(current_path); self.client = Some(client); self.get_bucket_info(); diff --git a/src/widgets/file_view.rs b/src/widgets/file_view.rs index f06be9c..5c3a96e 100644 --- a/src/widgets/file_view.rs +++ b/src/widgets/file_view.rs @@ -207,7 +207,7 @@ impl FileView { } fn mouse_wheel_zoom(&mut self, delta: f32) { - let delta = zoomratio((delta / 10.).max(-5.0).min(5.0), self.img_zoom); + let delta = zoomratio((delta / 10.).clamp(-5.0, 5.0), self.img_zoom); let new_scale = self.img_zoom + delta; // limit scale if new_scale > 0.01 && new_scale < 40. { diff --git a/src/widgets/status_bar.rs b/src/widgets/status_bar.rs index eee80f8..8bbe54f 100644 --- a/src/widgets/status_bar.rs +++ b/src/widgets/status_bar.rs @@ -29,7 +29,7 @@ pub fn status_bar_ui(ctx: &egui::Context, state: &mut State, _frame: &mut eframe ui.add(egui::Spinner::new().size(12.0)); } - if state.next_query.is_none() && !state.loading_more { + if !state.next_query.is_truncated && !state.loading_more { // ui.label("No More Data."); } diff --git a/src/widgets/toasts.rs b/src/widgets/toasts.rs index 54155de..e7be5d3 100644 --- a/src/widgets/toasts.rs +++ b/src/widgets/toasts.rs @@ -167,7 +167,7 @@ impl Toasts { } if response.clicked() { - egui_ctx.output_mut(|o| o.copied_text = toast.text.clone()); + egui_ctx.output_mut(|o| o.copied_text.clone_from(&toast.text)); toast.close(); }