diff --git a/CHANGELOG.md b/CHANGELOG.md index 9be79dd..b517dfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,4 +41,11 @@ ## [2.3.7] - 2024.11.24 ### Refactoring - 优化读取逻辑 -- :hammer: 重构代码!大量减少panic! \ No newline at end of file +- :hammer: 重构代码!大量减少panic! + +## [2.5.8] - 2025.1.7 +### Features :sparkles: +- 增加进度条支持(虽然很丑) +- 增加覆盖保存开关 +### Refactoring +- :hammer: 重构代码!使用mpsc进行线程通讯。 \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 346bc62..68f6cf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,7 +85,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -95,14 +95,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arbitrary" @@ -220,9 +220,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -238,9 +238,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cc" -version = "1.2.2" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" +checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" dependencies = [ "jobserver", "libc", @@ -265,16 +265,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -289,9 +289,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -299,9 +299,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -323,9 +323,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "color_quant" @@ -341,25 +341,25 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "console" -version = "0.15.8" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "unicode-width 0.1.14", - "windows-sys 0.52.0", + "once_cell", + "unicode-width", + "windows-sys", ] [[package]] @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -407,9 +407,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -435,15 +435,15 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -451,9 +451,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -485,9 +485,9 @@ dependencies = [ [[package]] name = "fdeflate" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" dependencies = [ "simd-adler32", ] @@ -659,7 +659,7 @@ dependencies = [ "console", "number_prefix", "portable-atomic", - "unicode-width 0.2.0", + "unicode-width", "web-time", ] @@ -721,9 +721,9 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.74" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ "once_cell", "wasm-bindgen", @@ -743,9 +743,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.167" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libfuzzer-sys" @@ -806,9 +806,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", "simd-adler32", @@ -832,7 +832,7 @@ checksum = "07dcca13d1740c0a665f77104803360da0bdb3323ecce2e93fa2c959a6d52806" [[package]] name = "ncmmiao" -version = "2.3.8" +version = "2.5.8" dependencies = [ "aes", "audiotags", @@ -950,9 +950,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "png" -version = "0.17.14" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -1021,9 +1021,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1186,18 +1186,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -1206,9 +1206,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ "itoa", "memchr", @@ -1260,9 +1260,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.90" +version = "2.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" dependencies = [ "proc-macro2", "quote", @@ -1365,12 +1365,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "unicode-width" version = "0.2.0" @@ -1424,9 +1418,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -1435,13 +1429,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -1450,9 +1443,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1460,9 +1453,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -1473,9 +1466,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-time" @@ -1499,7 +1492,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -1508,25 +1501,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[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.6", + "windows-targets", ] [[package]] @@ -1535,22 +1510,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -1559,46 +1519,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1611,48 +1553,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1661,9 +1579,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" dependencies = [ "memchr", ] @@ -1706,9 +1624,9 @@ dependencies = [ [[package]] name = "zune-jpeg" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768" +checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" dependencies = [ "zune-core", ] diff --git a/Cargo.toml b/Cargo.toml index e0d9cb0..d06877f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ncmmiao" -version = "2.3.8" +version = "2.5.8" edition = "2021" authors = ["Lkhsss "] description = "A magic tool convert ncm to flac" diff --git a/README.md b/README.md index b98a5df..e20b6e9 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ Options: # TODO :construction: - [x] 多线程支持 - [x] 自动添加封面 - - [ ] 解密进度条 + - [x] 解密进度条 - [x] 命令行解析 - [x] 自定义输出文件夹 - [x] 计时功能 - - [ ] 自动覆盖开关 + - [x] 自动覆盖开关 --- diff --git a/src/clap.rs b/src/clap.rs index cee8b26..1e2acf2 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -9,9 +9,14 @@ pub struct Cli { #[arg(short, long)] pub workers: Option, /// 需要解密的文件夹或文件 - #[arg(short, long, name = "输入文件/文件夹")] + #[arg(short, long, name = "输入文件/目录")] pub input: Vec, - #[arg(short, long, name = "输出文件夹", default_value = "NcmmiaoOutput")] + /// 输出目录 + #[arg(short, long, name = "输出目录", default_value = "NcmmiaoOutput")] pub output: Option, + + /// 强制覆盖保存开关 + #[arg(short,long,name="强制覆盖开关")] + pub forcesave:bool } diff --git a/src/main.rs b/src/main.rs index ce267ce..58a651d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,15 @@ -use std::{path::Path, sync::{Arc, Mutex}}; use ::clap::Parser; #[allow(unused_imports)] use log::{error, info, warn}; +use messager::Signals; +use std::time::Duration; +use std::{ + path::Path, + sync::{ + mpsc::{self, Sender}, + Arc, Mutex, + }, +}; use colored::Colorize; @@ -9,6 +17,7 @@ use walkdir::WalkDir; //遍历目录 mod clap; mod logger; +mod messager; mod ncmdump; mod threadpool; use ncmdump::Ncmfile; @@ -36,6 +45,10 @@ fn main() { let input = cli.input; let outputdir = cli.output.unwrap(); + let forcesave = cli.forcesave; + if forcesave{ + warn!("文件强制覆盖已开启!") + } let mut undumpfile = Vec::new(); // 该列表将存入文件的路径 @@ -79,22 +92,56 @@ fn main() { // 初始化线程池 let pool = threadpool::Pool::new(max_workers); info!("启用{}线程", max_workers); + // 初始化通讯 + let (tx, rx) = mpsc::channel(); + // 循环开始 for filepath in undumpfile { let output = outputdir.clone(); let successful = Arc::clone(&successful); - pool.execute(move || { - match Ncmfile::new(filepath.as_str()) { - Ok(mut n) => match n.dump(Path::new(&output)) { - Ok(_) => { - let mut num = successful.lock().unwrap(); - *num += 1;}, - Err(e) => error!("[{}]解密失败: {}", filepath.yellow(), e), - }, - Err(e) => error!("[{}]解密失败: {}", filepath.yellow(), e), - } + let sender: Sender = tx.clone(); + pool.execute(move || match Ncmfile::new(filepath.as_str()) { + Ok(mut n) => match n.dump(Path::new(&output), sender,forcesave) { + Ok(_) => { + let mut num = successful.lock().unwrap(); + *num += 1; + } + Err(e) => error!("[{}] 解密失败: {}", filepath.yellow(), e), + }, + Err(e) => error!("[{}] 解密失败: {}", filepath.yellow(), e), }); } + //循环到此结束 + //进度条 + + use indicatif::ProgressBar; + let progressbar = ProgressBar::new((taskcount) as u64) + .with_elapsed(Duration::from_millis(50)) + .with_message("破解中"); + //接受消息 + + for messages in rx { + match messages.signal { + Signals::Start => { + // progressbar.inc(1); + info!("[{}] 开始读取文件", messages.name) + } + Signals::Decrypt => { + // progressbar.inc(1); + info!("[{}] 开始解密", messages.name) + } + Signals::Save => { + // progressbar.inc(1); + info!("[{}] 保存文件", messages.name) + } + Signals::End => { + progressbar.inc(1); + info!("[{}] 成功!", messages.name) + } + } + } + + progressbar.finish_and_clear(); } let timecount = timer.compare(); let showtime = || { diff --git a/src/messager.rs b/src/messager.rs new file mode 100644 index 0000000..f4a420b --- /dev/null +++ b/src/messager.rs @@ -0,0 +1,42 @@ +use crate::messager; +use std::fmt::Debug; +use std::sync::mpsc; +pub struct Messager { + name: String, + sender: mpsc::Sender, +} + +pub struct Message { + pub name: String, + pub signal: Signals, +} + +pub enum Signals { + Start, + Decrypt, + Save, + End, +} + +impl Messager { + pub fn new(name: String, sender: mpsc::Sender) -> Self { + Self { name, sender } + } + pub fn send(&self, s: Signals) -> Result<(), std::sync::mpsc::SendError> { + self.sender.send(Message { + name: self.name.clone(), + signal: s, + }) + } +} +impl Debug for Message { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let message = match &self.signal { + Signals::Start => "开始破解".to_string(), + Signals::Decrypt => "开始解密".to_string(), + Signals::Save => "保存文件".to_string(), + Signals::End => "破解完成".to_string(), + }; + write!(f, "[{}] {}", self.name, message) + } +} diff --git a/src/ncmdump.rs b/src/ncmdump.rs index d329fff..7df3ed0 100644 --- a/src/ncmdump.rs +++ b/src/ncmdump.rs @@ -1,3 +1,4 @@ +use crate::messager; use aes::cipher::generic_array::typenum::U16; use aes::cipher::{generic_array::GenericArray, BlockDecrypt, KeyInit}; use aes::Aes128; @@ -8,12 +9,15 @@ use hex::decode; use lazy_static::lazy_static; #[allow(unused_imports)] use log::{debug, error, info, trace, warn}; +use messager::Signals; use serde_derive::{Deserialize, Serialize}; use serde_json::{self, Value}; +use std::fmt::Debug; use std::fs::{self, File}; use std::io::{BufReader, BufWriter, Read, Seek, SeekFrom, Write}; use std::path::{Path, PathBuf}; use std::str::from_utf8; +use std::sync::mpsc; use std::vec; use std::time::{SystemTime, UNIX_EPOCH}; @@ -144,13 +148,24 @@ impl Ncmfile { /// 解密函数 #[allow(unused_assignments)] - pub fn dump(&mut self, outputdir: &Path) -> Result<(), NcmError> { - info!("开始解密[{}]文件", self.fullfilename.yellow()); + pub fn dump( + &mut self, + outputdir: &Path, + tx: mpsc::Sender, + force_save:bool + ) -> Result<(), NcmError> { + + + + let messager = messager::Messager::new(self.fullfilename.clone(), tx); + let _ = messager.send(Signals::Start); + //TODO 通讯合法化 + // info!("开始解密[{}]文件", self.fullfilename.yellow()); // 获取magic header 。应为CTENFDAM let magic_header = match self.seekread(8) { Ok(header) => header, Err(_e) => { - return Err(NcmError::FileReadError); + return Err(NcmError::FileReadError); //TODO去除向上传播 } }; @@ -211,12 +226,39 @@ impl Ncmfile { Err(_) => return Err(NcmError::CannotReadMetaInfo), }; debug!("json_data: {}", json_data); - let data: Value = match serde_json::from_str(&json_data[..]){Ok(o) => o, + let data: Value = match serde_json::from_str(&json_data[..]) { + Ok(o) => o, Err(_) => return Err(NcmError::CannotReadMetaInfo), }; //解析json数据 data }; + //处理文件路径 + trace!("拼接文件路径"); + let path = { + let filename = format!( + "{}.{}", + self.filename, + meta_data.get("format").unwrap().as_str().unwrap() + ); + + // let filename = standardize_filename(filename); + debug!("文件名:{}", filename.yellow()); + //链级创建输出目录 + match fs::create_dir_all(outputdir) { + Err(_) => return Err(NcmError::FileWriteError), + _ => (), + }; + outputdir.join(filename) + }; + + debug!("文件路径: {:?}", path); + + // 先检查是否存在 + if !force_save && Path::new(&path).exists(){ + return Err(NcmError::ProtectFile); + } + // 跳过4个字节的校验码 trace!("读取校验码"); // let _crc32 = u32::from_le_bytes(self.seekread(4).unwrap().try_into().unwrap()) as u64; @@ -228,8 +270,7 @@ impl Ncmfile { // 获取图片数据的大小 trace!("获取图片数据的大小"); - let image_data_length = - u32::from_le_bytes(self.seekread(4)?.try_into().unwrap()) as u64; + let image_data_length = u32::from_le_bytes(self.seekread(4)?.try_into().unwrap()) as u64; // 读取图片,并写入文件当中 let image_data = self.seekread(image_data_length)?; //读取图片数据 @@ -280,6 +321,7 @@ impl Ncmfile { //解密音乐数据 trace!("解密音乐数据"); + let _ = messager.send(Signals::Decrypt); let mut music_data: Vec = Vec::new(); loop { let mut chunk = self.seekread_no_error(0x8000); @@ -325,30 +367,15 @@ impl Ncmfile { //退出循环,写入文件 - //处理文件路径 - trace!("拼接文件路径"); - let path = { - let filename = format!( - "{}.{}", - self.filename, - meta_data.get("format").unwrap().as_str().unwrap() - ); - - // let filename = standardize_filename(filename); - debug!("文件名:{}", filename.yellow()); - //链级创建输出目录 - match fs::create_dir_all(outputdir){Err(_)=>return Err(NcmError::FileWriteError),_=>()}; - outputdir.join(filename) - }; - - debug!("文件路径: {:?}", path); + + let _ = messager.send(Signals::Save); self.save(&path, music_data)?; { // 保存封面 - let mut tag = match Tag::new().read_from_path(&path){ - Ok(o)=>o, - Err(_)=>return Err(NcmError::CoverCannotSave) + let mut tag = match Tag::new().read_from_path(&path) { + Ok(o) => o, + Err(_) => return Err(NcmError::CoverCannotSave), }; let cover = Picture { mime_type: MimeType::Jpeg, @@ -368,19 +395,21 @@ impl Ncmfile { self.fullfilename.yellow(), "解密成功".bright_green() ); + let _ = messager.send(Signals::End); Ok(()) } - fn save(&mut self, path: &PathBuf, data: Vec)->Result<(),NcmError> { - let music_file = match File::create(path){ - Ok(o)=>o, - Err(_)=>return Err(NcmError::FileWriteError) + fn save(&mut self, path: &PathBuf, data: Vec) -> Result<(), NcmError> { + + let music_file = match File::create(path) { + Ok(o) => o, + Err(_) => return Err(NcmError::FileWriteError), }; let mut writer = BufWriter::new(music_file); let _ = writer.write_all(&data); // 关闭文件 - match writer.flush(){ - Ok(o)=>o, - Err(_)=>return Err(NcmError::FileWriteError) + match writer.flush() { + Ok(o) => o, + Err(_) => return Err(NcmError::FileWriteError), }; Ok(()) } @@ -544,7 +573,8 @@ pub enum NcmError { FileSkipError, FileWriteError, FullFilenameError, - FileNotFoundError, + FileNotFound, + ProtectFile, } impl std::error::Error for NcmError {} @@ -560,6 +590,7 @@ impl std::fmt::Display for NcmError { Self::FileReadError => write!(f, "读取文件时发生错误"), Self::FileWriteError => write!(f, "写入文件时错误"), Self::FullFilenameError => write!(f, "文件名不符合规范"), + Self::ProtectFile=>write!(f, "已关闭文件强制覆盖且文件已存在。使用-f或-forcesave开启强制覆盖。"), _ => write!(f, "未知错误"), } }