From d74cb6558b284242a72ef05a2f3bf9b2e6fb414b Mon Sep 17 00:00:00 2001 From: Cno Date: Thu, 2 May 2024 01:26:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E7=9A=84=E7=B4=A2=E5=BC=95=E5=BB=BA=E7=AB=8B=E4=BA=8E=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 653 +++++++++++++++++++++++++++++++++++++--- Cargo.toml | 1 + src/entrances/mirror.rs | 24 +- src/main.rs | 265 ++++++++-------- src/types/mirror.rs | 24 ++ src/utils/mirror.rs | 80 ++++- 6 files changed, 866 insertions(+), 181 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cf29c34..77f6bbaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,18 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.0.1" @@ -36,6 +48,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -100,6 +118,12 @@ version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "arrayref" version = "0.3.7" @@ -173,7 +197,7 @@ dependencies = [ "log", "parking", "polling", - "rustix", + "rustix 0.37.19", "slab", "socket2 0.4.9", "waker-fn", @@ -201,7 +225,7 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix", + "rustix 0.37.19", "signal-hook", "windows-sys 0.48.0", ] @@ -214,7 +238,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -231,7 +255,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -296,6 +320,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +[[package]] +name = "bitpacking" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c1d3e2bfd8d06048a179f7b17afc3188effa10385e7b00dc65af6aae732ea92" +dependencies = [ + "crunchy", +] + [[package]] name = "blake3" version = "1.3.3" @@ -369,6 +402,12 @@ dependencies = [ "libc", ] +[[package]] +name = "census" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4c707c6a209cbe82d10abd08e1ea8995e9ea937d2550646e02798948992be0" + [[package]] name = "cfg-if" version = "1.0.0" @@ -432,7 +471,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -532,6 +571,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -575,6 +623,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -615,7 +669,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -632,7 +686,7 @@ checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -713,6 +767,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + [[package]] name = "dunce" version = "1.0.4" @@ -838,7 +898,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -880,7 +940,7 @@ dependencies = [ "force-delete-win", "fs_extra", "lazy_static", - "memmap2", + "memmap2 0.5.10", "mslnk", "notify-rust", "path-clean", @@ -897,6 +957,7 @@ dependencies = [ "strum 0.25.0", "strum_macros 0.25.3", "sysinfo", + "tantivy", "tar", "toml", "trash", @@ -906,7 +967,7 @@ dependencies = [ "wildmatch", "winapi", "winreg 0.10.1", - "zstd", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -958,6 +1019,12 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "fastdivide" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59668941c55e5c186b8b58c391629af56774ec768f73c08bbcd56f09348eb00b" + [[package]] name = "fastrand" version = "1.9.0" @@ -974,7 +1041,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" dependencies = [ "cfg-if", - "rustix", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -1031,6 +1098,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs4" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dabded2e32cd57ded879041205c60a4a4c4bab47bd0fd2fa8b01f30849f02b" +dependencies = [ + "rustix 0.38.25", + "windows-sys 0.52.0", +] + [[package]] name = "fs_extra" version = "1.3.0" @@ -1117,6 +1194,19 @@ dependencies = [ "slab", ] +[[package]] +name = "generator" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows 0.48.0", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1183,6 +1273,10 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -1229,6 +1323,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "htmlescape" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" + [[package]] name = "http" version = "1.1.0" @@ -1385,6 +1485,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -1412,10 +1515,19 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix", + "rustix 0.37.19", "windows-sys 0.48.0", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.6" @@ -1446,12 +1558,24 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "levenshtein_automata" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2cdeb66e45e9f36bfad5bbdb4d2384e70936afbee843c6f6543f0c551ebb25" + [[package]] name = "libc" version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "link-cplusplus" version = "1.0.8" @@ -1467,6 +1591,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "log" version = "0.4.17" @@ -1476,6 +1606,35 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "pin-utils", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "lz4_flex" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" + [[package]] name = "mac-notification-sys" version = "0.5.6" @@ -1498,6 +1657,25 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "measure_time" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbefd235b0aadd181626f281e1d684e116972988c14c264e42069d5e8a5775cc" +dependencies = [ + "instant", + "log", +] + [[package]] name = "memchr" version = "2.5.0" @@ -1513,6 +1691,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.7.1" @@ -1537,6 +1724,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.2" @@ -1568,6 +1761,12 @@ dependencies = [ "log", ] +[[package]] +name = "murmurhash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2195bf6aa996a481483b29d62a7663eed3fe39600c460e323f8ff41e90bdd89b" + [[package]] name = "native-tls" version = "0.2.11" @@ -1632,6 +1831,16 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "notify-rust" version = "4.8.0" @@ -1654,6 +1863,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1671,6 +1890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1723,9 +1943,18 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "oneshot" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "6f6640c6bda7731b1fdbab747981a0f896dd1fedaf9f4a53fa237a04a84431f4" +dependencies = [ + "loom", +] [[package]] name = "openssl" @@ -1750,7 +1979,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -1781,6 +2010,21 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "ownedbytes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3a059efb063b8f425b948e042e6b9bd85edfe60e913630ed727b23e2dfcc558" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "parking" version = "2.1.0" @@ -1835,7 +2079,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -1908,9 +2152,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.27" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1955,6 +2199,16 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand", +] + [[package]] name = "rayon" version = "1.7.0" @@ -2014,15 +2268,36 @@ checksum = "d1a59b5d8e97dee33696bf13c5ba8ab85341c002922fba050069326b9c498974" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.2", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + [[package]] name = "reqwest" version = "0.12.4" @@ -2066,12 +2341,28 @@ dependencies = [ "winreg 0.52.0", ] +[[package]] +name = "rust-stemmers" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46a2036019fdb888131db7a4c847a1063a7493f971ed94ea82c67eada63ca54" +dependencies = [ + "serde", + "serde_derive", +] + [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.37.19" @@ -2082,7 +2373,20 @@ dependencies = [ "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys 0.4.13", "windows-sys 0.48.0", ] @@ -2158,6 +2462,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.1.0" @@ -2216,7 +2526,7 @@ checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -2238,7 +2548,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -2264,6 +2574,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shell-words" version = "1.1.0" @@ -2289,6 +2608,15 @@ dependencies = [ "libc", ] +[[package]] +name = "sketches-ddsketch" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85636c14b73d81f541e525f585c0a2109e6744e1565b5c1668e31c70c10ed65c" +dependencies = [ + "serde", +] + [[package]] name = "slab" version = "0.4.8" @@ -2324,6 +2652,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2379,7 +2713,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -2401,9 +2735,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -2452,6 +2786,147 @@ dependencies = [ "libc", ] +[[package]] +name = "tantivy" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8d0582f186c0a6d55655d24543f15e43607299425c5ad8352c242b914b31856" +dependencies = [ + "aho-corasick", + "arc-swap", + "base64 0.22.1", + "bitpacking", + "byteorder", + "census", + "crc32fast", + "crossbeam-channel", + "downcast-rs", + "fastdivide", + "fnv", + "fs4", + "htmlescape", + "itertools", + "levenshtein_automata", + "log", + "lru", + "lz4_flex", + "measure_time", + "memmap2 0.9.4", + "num_cpus", + "once_cell", + "oneshot", + "rayon", + "regex", + "rust-stemmers", + "rustc-hash", + "serde", + "serde_json", + "sketches-ddsketch", + "smallvec", + "tantivy-bitpacker", + "tantivy-columnar", + "tantivy-common", + "tantivy-fst", + "tantivy-query-grammar", + "tantivy-stacker", + "tantivy-tokenizer-api", + "tempfile", + "thiserror", + "time 0.3.22", + "uuid", + "winapi", +] + +[[package]] +name = "tantivy-bitpacker" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284899c2325d6832203ac6ff5891b297fc5239c3dc754c5bc1977855b23c10df" +dependencies = [ + "bitpacking", +] + +[[package]] +name = "tantivy-columnar" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12722224ffbe346c7fec3275c699e508fd0d4710e629e933d5736ec524a1f44e" +dependencies = [ + "downcast-rs", + "fastdivide", + "itertools", + "serde", + "tantivy-bitpacker", + "tantivy-common", + "tantivy-sstable", + "tantivy-stacker", +] + +[[package]] +name = "tantivy-common" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8019e3cabcfd20a1380b491e13ff42f57bb38bf97c3d5fa5c07e50816e0621f4" +dependencies = [ + "async-trait", + "byteorder", + "ownedbytes", + "serde", + "time 0.3.22", +] + +[[package]] +name = "tantivy-fst" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d60769b80ad7953d8a7b2c70cdfe722bbcdcac6bccc8ac934c40c034d866fc18" +dependencies = [ + "byteorder", + "regex-syntax 0.8.3", + "utf8-ranges", +] + +[[package]] +name = "tantivy-query-grammar" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "847434d4af57b32e309f4ab1b4f1707a6c566656264caa427ff4285c4d9d0b82" +dependencies = [ + "nom", +] + +[[package]] +name = "tantivy-sstable" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c69578242e8e9fc989119f522ba5b49a38ac20f576fc778035b96cc94f41f98e" +dependencies = [ + "tantivy-bitpacker", + "tantivy-common", + "tantivy-fst", + "zstd 0.13.1", +] + +[[package]] +name = "tantivy-stacker" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56d6ff5591fc332739b3ce7035b57995a3ce29a93ffd6012660e0949c956ea8" +dependencies = [ + "murmurhash32", + "rand_distr", + "tantivy-common", +] + +[[package]] +name = "tantivy-tokenizer-api" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0dcade25819a89cfe6f17d932c9cedff11989936bf6dd4f336d50392053b04" +dependencies = [ + "serde", +] + [[package]] name = "tar" version = "0.4.38" @@ -2484,7 +2959,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -2514,7 +2989,17 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", ] [[package]] @@ -2534,8 +3019,10 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" dependencies = [ + "itoa", "serde", "time-core", + "time-macros", ] [[package]] @@ -2544,6 +3031,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +[[package]] +name = "time-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +dependencies = [ + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2676,7 +3172,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", ] [[package]] @@ -2686,6 +3182,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -2793,12 +3319,34 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8-ranges" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba" + [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vc-ltl" version = "5.0.7" @@ -2865,7 +3413,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -2899,7 +3447,7 @@ checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3362,13 +3910,42 @@ dependencies = [ "zvariant", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "zstd" version = "0.12.3+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" dependencies = [ - "zstd-safe", + "zstd-safe 6.0.5+zstd.1.5.4", +] + +[[package]] +name = "zstd" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +dependencies = [ + "zstd-safe 7.1.0", ] [[package]] @@ -3381,14 +3958,22 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +dependencies = [ + "zstd-sys", +] + [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.10+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" dependencies = [ "cc", - "libc", "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index b5c1031c..0b54ed1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ shell-words = "1.1.0" strum = "0.25.0" strum_macros = "0.25.3" sysinfo = "0.28.0" +tantivy = "0.22.0" tar = "0.4.38" toml = { version = "0.5.11", features = ["preserve_order"] } trash = "3.0.1" diff --git a/src/entrances/mirror.rs b/src/entrances/mirror.rs index ecc8a705..7102b2ab 100644 --- a/src/entrances/mirror.rs +++ b/src/entrances/mirror.rs @@ -56,17 +56,17 @@ pub fn mirror_remove(name: &String) -> Result<()> { try_recycle(p) } -#[test] -fn test_mirror_add() { - mirror_add(&"http://localhost:3000/api/hello".to_string(), None).unwrap(); -} +// #[test] +// fn test_mirror_add() { +// mirror_add(&"http://localhost:3000/api/hello".to_string(), None).unwrap(); +// } -#[test] -fn test_mirror_update() { - mirror_update(&"official".to_string()).unwrap(); -} +// #[test] +// fn test_mirror_update() { +// mirror_update(&"official".to_string()).unwrap(); +// } -#[test] -fn test_mirror_remove() { - mirror_remove(&"official".to_string()).unwrap(); -} +// #[test] +// fn test_mirror_remove() { +// mirror_remove(&"official".to_string()).unwrap(); +// } diff --git a/src/main.rs b/src/main.rs index 45809d59..b76fd90f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,132 +1,133 @@ -#[macro_use] -extern crate lazy_static; -extern crate tar; - -mod ca; -mod compression; -mod entrances; -mod executor; -mod parsers; -mod signature; -#[macro_use] -mod types; -#[macro_use] -mod utils; - -use anyhow::{anyhow, Result}; - -use entrances::meta; -use std::fs::write; -use std::process::exit; - -use self::types::cli::{Action, ActionConfig, Args}; -use crate::entrances::config::{config_get, config_init, config_list, config_set, config_which}; -use crate::entrances::{ - clean, info, install_using_package, list, pack, uninstall, update_using_package, -}; - -#[cfg(not(tarpaulin_include))] -fn router(action: Action) -> Result { - // 环境变量读取 - let verify_signature = envmnt::get_or("OFFLINE", "false") == String::from("false"); - - // 匹配入口 - match action { - Action::Install { package } => install_using_package(&package, verify_signature) - .map(|_| format!("Success:Package '{package}' installed successfully")), - Action::Update { package } => update_using_package(&package, verify_signature) - .map(|_| format!("Success:Package '{package}' updated successfully")), - Action::Uninstall { package_name } => uninstall(&package_name) - .map(|_| format!("Success:Package '{package_name}' uninstalled successfully")), - Action::Info { package_name } => info(None, &package_name).map(|res| format!("{res:#?}")), - Action::List => list().map(|list| { - if list.len() == 0 { - return "No installed package".to_string(); - } - let res: String = - list.into_iter() - .fold(String::from("\nInstalled packages:\n"), |acc, node| { - return acc - + &format!( - " {name} {version}\n", - name = node.name, - version = node.local.unwrap().version - ); - }); - res - }), - Action::Pack { - source_dir, - into_file, - } => pack(&source_dir, into_file, verify_signature) - .map(|location| format!("Success:Package has been stored at '{location}'")), - Action::Meta { - source_package, - save_at, - } => { - let res = meta(&source_package, verify_signature)?; - let text = serde_json::to_string_pretty(&res) - .map_err(|e| anyhow!("Error:Failed to deserialize result : {e}"))?; - if let Some(into) = save_at { - write(&into, text) - .map_err(|e| anyhow!("Error:Failed to write to '{into}' : {e}"))?; - return Ok(format!("Success:Meta report saved at '{into}'")); - } else { - return Ok(text); - } - } - - Action::Clean => clean().map(|_| format!("Success:Cleaned")), - Action::Config { operation } => match operation { - ActionConfig::Set { table, key, value } => config_set(&table, &key, &value) - .map(|_| format!("Success:Config value of '{key}' has been set to '{value}'")), - ActionConfig::Get { table, key } => config_get(&table, &key), - ActionConfig::List => config_list(), - ActionConfig::Init => config_init() - .map(|location| format!("Success:Initial config stored at '{location}'")), - ActionConfig::Which => config_which(), - }, - } -} - -#[cfg(not(tarpaulin_include))] -fn main() { - use clap::Parser; - - use crate::utils::launch_clean; - - let args = Args::parse(); - - // 配置环境变量 - if args.qa { - envmnt::set("QA", "true"); - } - if args.debug || args.qa || cfg!(debug_assertions) { - log!("Warning:Debug mode enabled"); - envmnt::set("DEBUG", "true"); - } else { - launch_clean().unwrap(); - } - if args.offline { - log!("Warning:Offline mode enabled, ept couldn't guarantee security or integrality of packages"); - envmnt::set("OFFLINE", "true"); - } - if args.yes { - log!("Warning:Confirmation mode enabled"); - envmnt::set("CONFIRM", "true"); - } - if args.strict { - log!("Warning:Strict mode enabled"); - envmnt::set("STRICT", "true"); - } - - // 使用路由器匹配入口 - let res = router(args.action); - if res.is_ok() { - log!("{msg}", msg = res.unwrap()); - exit(0); - } else { - log!("{msg}", msg = res.unwrap_err()); - exit(1); - } -} +#[macro_use] +extern crate lazy_static; +extern crate tar; +#[macro_use] +extern crate tantivy; +mod ca; +mod compression; +mod entrances; +mod executor; +mod parsers; +mod signature; +#[macro_use] +mod types; +#[macro_use] +mod utils; + +use anyhow::{anyhow, Result}; + +use entrances::meta; +use std::fs::write; +use std::process::exit; + +use self::types::cli::{Action, ActionConfig, Args}; +use crate::entrances::config::{config_get, config_init, config_list, config_set, config_which}; +use crate::entrances::{ + clean, info, install_using_package, list, pack, uninstall, update_using_package, +}; + +#[cfg(not(tarpaulin_include))] +fn router(action: Action) -> Result { + // 环境变量读取 + let verify_signature = envmnt::get_or("OFFLINE", "false") == String::from("false"); + + // 匹配入口 + match action { + Action::Install { package } => install_using_package(&package, verify_signature) + .map(|_| format!("Success:Package '{package}' installed successfully")), + Action::Update { package } => update_using_package(&package, verify_signature) + .map(|_| format!("Success:Package '{package}' updated successfully")), + Action::Uninstall { package_name } => uninstall(&package_name) + .map(|_| format!("Success:Package '{package_name}' uninstalled successfully")), + Action::Info { package_name } => info(None, &package_name).map(|res| format!("{res:#?}")), + Action::List => list().map(|list| { + if list.len() == 0 { + return "No installed package".to_string(); + } + let res: String = + list.into_iter() + .fold(String::from("\nInstalled packages:\n"), |acc, node| { + return acc + + &format!( + " {name} {version}\n", + name = node.name, + version = node.local.unwrap().version + ); + }); + res + }), + Action::Pack { + source_dir, + into_file, + } => pack(&source_dir, into_file, verify_signature) + .map(|location| format!("Success:Package has been stored at '{location}'")), + Action::Meta { + source_package, + save_at, + } => { + let res = meta(&source_package, verify_signature)?; + let text = serde_json::to_string_pretty(&res) + .map_err(|e| anyhow!("Error:Failed to deserialize result : {e}"))?; + if let Some(into) = save_at { + write(&into, text) + .map_err(|e| anyhow!("Error:Failed to write to '{into}' : {e}"))?; + return Ok(format!("Success:Meta report saved at '{into}'")); + } else { + return Ok(text); + } + } + + Action::Clean => clean().map(|_| format!("Success:Cleaned")), + Action::Config { operation } => match operation { + ActionConfig::Set { table, key, value } => config_set(&table, &key, &value) + .map(|_| format!("Success:Config value of '{key}' has been set to '{value}'")), + ActionConfig::Get { table, key } => config_get(&table, &key), + ActionConfig::List => config_list(), + ActionConfig::Init => config_init() + .map(|location| format!("Success:Initial config stored at '{location}'")), + ActionConfig::Which => config_which(), + }, + } +} + +#[cfg(not(tarpaulin_include))] +fn main() { + use clap::Parser; + + use crate::utils::launch_clean; + + let args = Args::parse(); + + // 配置环境变量 + if args.qa { + envmnt::set("QA", "true"); + } + if args.debug || args.qa || cfg!(debug_assertions) { + log!("Warning:Debug mode enabled"); + envmnt::set("DEBUG", "true"); + } else { + launch_clean().unwrap(); + } + if args.offline { + log!("Warning:Offline mode enabled, ept couldn't guarantee security or integrality of packages"); + envmnt::set("OFFLINE", "true"); + } + if args.yes { + log!("Warning:Confirmation mode enabled"); + envmnt::set("CONFIRM", "true"); + } + if args.strict { + log!("Warning:Strict mode enabled"); + envmnt::set("STRICT", "true"); + } + + // 使用路由器匹配入口 + let res = router(args.action); + if res.is_ok() { + log!("{msg}", msg = res.unwrap()); + exit(0); + } else { + log!("{msg}", msg = res.unwrap_err()); + exit(1); + } +} diff --git a/src/types/mirror.rs b/src/types/mirror.rs index 75c291e7..80c36bc9 100644 --- a/src/types/mirror.rs +++ b/src/types/mirror.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use crate::utils::mirror::filter_service_from_meta; use anyhow::Result; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -112,3 +114,25 @@ impl Verifiable for MirrorHello { Ok(()) } } + +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct MirrorPkgSoftware { + pub timestamp: u64, + pub url_template: String, + pub tree: HashMap>, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct TreeItem { + pub name: String, + pub releases: Vec, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct MirrorPkgSoftwareRelease { + pub file_name: String, + pub size: u64, + pub timestamp: u64, + pub integrity: Option, + // meta 和 permissions 在这里被省略 +} diff --git a/src/utils/mirror.rs b/src/utils/mirror.rs index 37e2c9e4..d0b052b5 100644 --- a/src/utils/mirror.rs +++ b/src/utils/mirror.rs @@ -1,13 +1,20 @@ -use std::path::PathBuf; - use anyhow::{anyhow, Result}; use fs_extra::file::read_to_string; +use serde_json::Value; +use std::collections::HashMap; +use std::path::PathBuf; +use tantivy::collector::TopDocs; +use tantivy::query::QueryParser; +use tantivy::schema::*; +use tantivy::Index; +use tantivy::ReloadPolicy; + use toml::from_str; use crate::{ p2s, types::{ - mirror::{MirrorHello, Service, ServiceKeys}, + mirror::{MirrorHello, MirrorPkgSoftware, Service, ServiceKeys}, verifiable::Verifiable, }, utils::get_path_mirror, @@ -38,3 +45,70 @@ pub fn filter_service_from_meta(hello: MirrorHello, key: ServiceKeys) -> Result< )) } } + +fn get_schema() -> Result { + let mut schema_builder = Schema::builder(); + schema_builder.add_text_field("name", TEXT | STORED); + Ok(schema_builder.build()) +} + +// 为包构建索引 +pub fn build_index_for_mirror(content: MirrorPkgSoftware, dir: PathBuf) -> Result<()> { + let schema = get_schema()?; + let index = Index::create_in_dir(&dir, schema.clone())?; + let mut index_writer = index.writer(50_000_000)?; + let name = schema.get_field("name")?; + index_writer + .add_document(doc!( + name => "Visual Studio Code", + )) + .map_err(|e| anyhow!("Error:Failed to add document to index writer : '{e}'"))?; + index_writer.commit()?; + + Ok(()) +} + +// 从索引中搜索内容 +pub fn search_index_for_mirror(text: &String, dir: PathBuf) -> Result<()> { + let schema = get_schema()?; + let name = schema.get_field("name")?; + + let index = Index::open_in_dir(&dir)?; + let reader = index + .reader_builder() + .reload_policy(ReloadPolicy::OnCommitWithDelay) + .try_into()?; + let searcher = reader.searcher(); + let query_parser = QueryParser::for_index(&index, vec![name]); + let query = query_parser.parse_query(text)?; + let top_docs = searcher.search(&query, &TopDocs::with_limit(10))?; + + for (_score, doc_address) in top_docs { + let retrieved_doc: TantivyDocument = searcher.doc(doc_address)?; + println!("{retrieved_doc:#?}"); + } + + Ok(()) +} + +#[test] +fn test_build_index_for_mirror() { + build_index_for_mirror( + MirrorPkgSoftware { + timestamp: 0, + url_template: String::new(), + tree: HashMap::new(), + }, + get_path_mirror().unwrap().join("official").join("index"), + ) + .unwrap(); +} + +#[test] +fn test_search_index_for_mirror() { + search_index_for_mirror( + &"Code".to_string(), + get_path_mirror().unwrap().join("official").join("index"), + ) + .unwrap(); +}