mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
perf: partial rendering progress and composite into a complete UI to reduce CPU consumption caused by frequent progress updates (#509)
This commit is contained in:
parent
ee8b8fc730
commit
a1c963accc
30 changed files with 324 additions and 210 deletions
194
Cargo.lock
generated
194
Cargo.lock
generated
|
|
@ -72,9 +72,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.5"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
|
||||
checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
|
|
@ -132,9 +132,9 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
|
|||
|
||||
[[package]]
|
||||
name = "async-priority-channel"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c21678992e1b21bebfe2bc53ab5f5f68c106eddab31b24e0bb06e9b715a86640"
|
||||
checksum = "acde96f444d31031f760c5c43dc786b97d3e1cb2ee49dd06898383fe9a999758"
|
||||
dependencies = [
|
||||
"event-listener",
|
||||
]
|
||||
|
|
@ -162,9 +162,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.5"
|
||||
version = "0.21.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
|
||||
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||
|
||||
[[package]]
|
||||
name = "better-panic"
|
||||
|
|
@ -281,9 +281,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.4.12"
|
||||
version = "4.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
|
||||
checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
|
|
@ -291,9 +291,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.4.12"
|
||||
version = "4.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9"
|
||||
checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
|
@ -303,9 +303,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.4.5"
|
||||
version = "4.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a51919c5608a32e34ea1d6be321ad070065e17613e168c5b6977024290f2630b"
|
||||
checksum = "97aeaa95557bd02f23fbb662f981670c3d20c5a26e69f7354b28f57092437fcd"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
|
@ -339,7 +339,7 @@ dependencies = [
|
|||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -372,15 +372,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.15.7"
|
||||
name = "concurrent-queue"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
|
||||
checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.15.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"windows-sys 0.45.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -400,44 +409,37 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.10"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2"
|
||||
checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751"
|
||||
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.17"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.18"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
|
|
@ -541,9 +543,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
|||
|
||||
[[package]]
|
||||
name = "erased-serde"
|
||||
version = "0.3.31"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c"
|
||||
checksum = "55d05712b2d8d88102bc9868020c9e5c7a1f5527c452b9b97450a1d006140ba7"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
|
@ -570,9 +572,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "2.5.3"
|
||||
version = "4.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||
checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e"
|
||||
dependencies = [
|
||||
"concurrent-queue",
|
||||
"parking",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
|
|
@ -720,7 +727,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -765,9 +772,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.11"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
|
||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
|
|
@ -981,9 +988,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.66"
|
||||
version = "0.3.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
|
||||
checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
|
@ -1031,9 +1038,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.151"
|
||||
version = "0.2.152"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
|
|
@ -1097,9 +1104,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "luajit-src"
|
||||
version = "210.5.3+29b0b28"
|
||||
version = "210.5.4+c525bcb"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c2bb89013916ce5c949f01a1fbd6d435a58e1d980767a791d755911211d792d"
|
||||
checksum = "2a10ab4ed12d22cb50ef43ece4f6c5ca594b2d2480019e87facfd422225a9908"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"which",
|
||||
|
|
@ -1160,9 +1167,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mlua"
|
||||
version = "0.9.2"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c81f8ac20188feb5461a73eabb22a34dd09d6d58513535eb587e46bff6ba250"
|
||||
checksum = "069264935e816c85884b99e88c8b408d6d92e40ae8760f726c983526a53546b5"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"erased-serde",
|
||||
|
|
@ -1178,9 +1185,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mlua-sys"
|
||||
version = "0.4.0"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc29228347d6bdc9e613dc95c69df2817f755434ee0f7f3b27b57755fe238b7f"
|
||||
checksum = "4655631a02e3739d014951291ecfa08db49c4da3f7f8c6f3931ed236af5dd78e"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
|
|
@ -1191,9 +1198,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mlua_derive"
|
||||
version = "0.9.0"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f359220f24e6452dd82a3f50d7242d4aab822b5594798048e953d7a9e0314c6"
|
||||
checksum = "15f677457e995582451fc52a5c5aa02c13d2ea1e0f44afcf87dd4dc2961f3b1c"
|
||||
dependencies = [
|
||||
"itertools 0.11.0",
|
||||
"once_cell",
|
||||
|
|
@ -1201,7 +1208,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1364,6 +1371,12 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
|
|
@ -1476,9 +1489,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.74"
|
||||
version = "1.0.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"
|
||||
checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
@ -1664,9 +1677,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.194"
|
||||
version = "1.0.195"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773"
|
||||
checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
|
@ -1683,20 +1696,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.194"
|
||||
version = "1.0.195"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0"
|
||||
checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.110"
|
||||
version = "1.0.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257"
|
||||
checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
|
|
@ -1850,7 +1863,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1866,9 +1879,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.46"
|
||||
version = "2.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"
|
||||
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -1912,7 +1925,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2009,7 +2022,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2102,7 +2115,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2142,9 +2155,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "trash"
|
||||
version = "3.1.2"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c646008e5144d988005bec12b1e56f5e0a951e957176686815eba8b025e0418"
|
||||
checksum = "6e7b1a28f9550f43ac27987f2144d7798520c6dee6a7eb1dedfe3131e3c257e3"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
@ -2272,9 +2285,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
|||
|
||||
[[package]]
|
||||
name = "vergen"
|
||||
version = "8.2.6"
|
||||
version = "8.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1290fd64cc4e7d3c9b07d7f333ce0ce0007253e32870e632624835cc80b83939"
|
||||
checksum = "f2066fbfd3bfbadab28cab8bae840c9e74917bc6deeef2ed0781f2eb2fdfafdb"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"rustversion",
|
||||
|
|
@ -2305,9 +2318,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.89"
|
||||
version = "0.2.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
|
||||
checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
|
|
@ -2315,24 +2328,24 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.89"
|
||||
version = "0.2.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
|
||||
checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.89"
|
||||
version = "0.2.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
|
||||
checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
|
|
@ -2340,22 +2353,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.89"
|
||||
version = "0.2.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
|
||||
checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.89"
|
||||
version = "0.2.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
|
||||
checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
|
|
@ -2425,15 +2438,6 @@ dependencies = [
|
|||
"windows-targets 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
|
|
@ -2625,9 +2629,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.5.31"
|
||||
version = "0.5.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c"
|
||||
checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
@ -2820,7 +2824,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.46",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ rules = [
|
|||
]
|
||||
|
||||
[tasks]
|
||||
micro_workers = 5
|
||||
macro_workers = 10
|
||||
micro_workers = 10
|
||||
macro_workers = 25
|
||||
bizarre_retry = 5
|
||||
image_alloc = 536870912 # 512MB
|
||||
image_bound = [ 0, 0 ]
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ use crate::tasks::Tasks;
|
|||
|
||||
impl Tasks {
|
||||
pub fn cancel(&mut self, _: &Exec) {
|
||||
let id = self.scheduler.running.read().get_id(self.cursor);
|
||||
let id = self.scheduler.running.lock().get_id(self.cursor);
|
||||
if id.map(|id| self.scheduler.cancel(id)) != Some(true) {
|
||||
return;
|
||||
}
|
||||
|
||||
let len = self.scheduler.running.read().len();
|
||||
let len = self.scheduler.running.lock().len();
|
||||
self.cursor = self.cursor.min(len.saturating_sub(1));
|
||||
render!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::tasks::Tasks;
|
|||
|
||||
impl Tasks {
|
||||
pub fn inspect(&self, _: &Exec) {
|
||||
let Some(id) = self.scheduler.running.read().get_id(self.cursor) else {
|
||||
let Some(id) = self.scheduler.running.lock().get_id(self.cursor) else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ impl Tasks {
|
|||
let (tx, mut rx) = mpsc::unbounded_channel();
|
||||
|
||||
let buffered = {
|
||||
let mut running = scheduler.running.write();
|
||||
let mut running = scheduler.running.lock();
|
||||
let Some(task) = running.get_mut(id) else { return };
|
||||
|
||||
task.logger = Some(tx);
|
||||
|
|
@ -45,8 +45,8 @@ impl Tasks {
|
|||
stdout.write_all(line.as_bytes()).ok();
|
||||
stdout.write_all(b"\r\n").ok();
|
||||
}
|
||||
_ = time::sleep(time::Duration::from_millis(100)) => {
|
||||
if scheduler.running.read().get(id).is_none() {
|
||||
_ = time::sleep(time::Duration::from_millis(500)) => {
|
||||
if scheduler.running.lock().get(id).is_none() {
|
||||
stdout().write_all(b"Task finished, press `q` to quit\r\n").ok();
|
||||
break;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ impl Tasks {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(task) = scheduler.running.write().get_mut(id) {
|
||||
if let Some(task) = scheduler.running.lock().get_mut(id) {
|
||||
task.logger = None;
|
||||
}
|
||||
while quit[0] != b'q' {
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@ mod cancel;
|
|||
mod inspect;
|
||||
mod open;
|
||||
mod toggle;
|
||||
mod update;
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
use yazi_shared::{emit, event::Exec, render, Layer};
|
||||
|
||||
use crate::tasks::{Tasks, TasksProgress};
|
||||
|
||||
pub struct Opt {
|
||||
progress: TasksProgress,
|
||||
}
|
||||
|
||||
impl TryFrom<&Exec> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(e: &Exec) -> Result<Self, Self::Error> { e.take_data().ok_or(()) }
|
||||
}
|
||||
|
||||
impl Tasks {
|
||||
pub fn _update(progress: TasksProgress) {
|
||||
emit!(Call(Exec::call("update", vec![]).with_data(Opt { progress }).vec(), Layer::Tasks));
|
||||
}
|
||||
|
||||
pub fn update(&mut self, opt: impl TryInto<Opt>) {
|
||||
let Ok(opt) = opt.try_into() else {
|
||||
return;
|
||||
};
|
||||
|
||||
self.progress = opt.progress;
|
||||
render!();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ use tokio::time::sleep;
|
|||
use tracing::debug;
|
||||
use yazi_config::{manager::SortBy, open::Opener, plugin::{PluginRule, MAX_PRELOADERS}, popup::InputCfg, OPEN, PLUGIN};
|
||||
use yazi_scheduler::{Scheduler, TaskSummary};
|
||||
use yazi_shared::{fs::{File, Url}, term::Term, MIME_DIR};
|
||||
use yazi_shared::{emit, event::Exec, fs::{File, Url}, term::Term, Layer, MIME_DIR};
|
||||
|
||||
use super::{TasksProgress, TASKS_PADDING, TASKS_PERCENT};
|
||||
use crate::{folder::Files, input::Input};
|
||||
|
|
@ -32,10 +32,10 @@ impl Tasks {
|
|||
loop {
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
|
||||
let new = TasksProgress::from(&*running.read());
|
||||
let new = TasksProgress::from(&*running.lock());
|
||||
if last != new {
|
||||
last = new;
|
||||
Tasks::_update(new);
|
||||
emit!(Call(Exec::call("update_progress", vec![]).with_data(new).vec(), Layer::App));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -49,7 +49,7 @@ impl Tasks {
|
|||
}
|
||||
|
||||
pub fn paginate(&self) -> Vec<TaskSummary> {
|
||||
let running = self.scheduler.running.read();
|
||||
let running = self.scheduler.running.lock();
|
||||
running.values().take(Self::limit()).map(Into::into).collect()
|
||||
}
|
||||
|
||||
|
|
@ -236,5 +236,5 @@ impl Tasks {
|
|||
|
||||
impl Tasks {
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize { self.scheduler.running.read().len() }
|
||||
pub fn len(&self) -> usize { self.scheduler.running.lock().len() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@ mod quit;
|
|||
mod render;
|
||||
mod resize;
|
||||
mod stop;
|
||||
mod update_progress;
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ impl App {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let mut patches = vec![];
|
||||
let mut patch = vec![];
|
||||
for x in frame.area.left()..frame.area.right() {
|
||||
for y in frame.area.top()..frame.area.bottom() {
|
||||
let cell = frame.buffer.get(x, y);
|
||||
if cell.skip {
|
||||
patches.push((x, y, cell.clone()));
|
||||
patch.push((x, y, cell.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
term.backend_mut().draw(patches.iter().map(|(x, y, cell)| (*x, *y, cell)))?;
|
||||
term.backend_mut().draw(patch.iter().map(|(x, y, cell)| (*x, *y, cell)))?;
|
||||
if let Some((x, y)) = self.cx.cursor() {
|
||||
term.show_cursor()?;
|
||||
term.set_cursor(x, y)?;
|
||||
|
|
|
|||
41
yazi-fm/src/app/commands/update_progress.rs
Normal file
41
yazi-fm/src/app/commands/update_progress.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use ratatui::backend::Backend;
|
||||
use yazi_core::tasks::TasksProgress;
|
||||
use yazi_shared::event::Exec;
|
||||
|
||||
use crate::{app::App, components::Progress, lives::Lives};
|
||||
|
||||
pub struct Opt {
|
||||
progress: TasksProgress,
|
||||
}
|
||||
|
||||
impl TryFrom<&Exec> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(e: &Exec) -> Result<Self, Self::Error> {
|
||||
Ok(Self { progress: e.take_data().ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub(crate) fn update_progress(&mut self, opt: impl TryInto<Opt>) {
|
||||
let Ok(opt) = opt.try_into() else {
|
||||
return;
|
||||
};
|
||||
|
||||
self.cx.tasks.progress = opt.progress;
|
||||
let Some(term) = &mut self.term else {
|
||||
return;
|
||||
};
|
||||
|
||||
Lives::partial_scope(&self.cx, |_| {
|
||||
for patch in Progress::partial_render(term.current_buffer_mut()) {
|
||||
term.backend_mut().draw(patch.iter().map(|(x, y, cell)| (*x, *y, cell))).ok();
|
||||
if let Some((x, y)) = self.cx.cursor() {
|
||||
term.show_cursor().ok();
|
||||
term.set_cursor(x, y).ok();
|
||||
}
|
||||
term.backend_mut().flush().ok();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3,9 +3,11 @@
|
|||
mod header;
|
||||
mod manager;
|
||||
mod preview;
|
||||
mod progress;
|
||||
mod status;
|
||||
|
||||
pub(super) use header::*;
|
||||
pub(super) use manager::*;
|
||||
pub(super) use preview::*;
|
||||
pub(super) use progress::*;
|
||||
pub(super) use status::*;
|
||||
|
|
|
|||
43
yazi-fm/src/components/progress.rs
Normal file
43
yazi-fm/src/components/progress.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use std::mem;
|
||||
|
||||
use mlua::{AnyUserData, Table, TableExt};
|
||||
use tracing::error;
|
||||
use yazi_plugin::{cast_to_renderable, LUA};
|
||||
|
||||
pub(crate) struct Progress;
|
||||
|
||||
impl Progress {
|
||||
pub(crate) fn partial_render(
|
||||
buf: &mut ratatui::buffer::Buffer,
|
||||
) -> Vec<Vec<(u16, u16, ratatui::buffer::Cell)>> {
|
||||
let mut patches = vec![];
|
||||
let mut f = || {
|
||||
let comp: Table = LUA.globals().get("Progress")?;
|
||||
for widget in comp.call_method::<_, Vec<AnyUserData>>("partial_render", ())? {
|
||||
let Some(w) = cast_to_renderable(widget) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let area = w.area();
|
||||
w.render(buf);
|
||||
|
||||
let mut patch = Vec::with_capacity(area.width as usize * area.height as usize);
|
||||
for x in area.left()..area.right() {
|
||||
for y in area.top()..area.bottom() {
|
||||
patch.push((x, y, mem::take(buf.get_mut(x, y))));
|
||||
}
|
||||
}
|
||||
|
||||
buf.reset();
|
||||
patches.push(patch);
|
||||
}
|
||||
|
||||
Ok::<_, anyhow::Error>(())
|
||||
};
|
||||
|
||||
if let Err(e) = f() {
|
||||
error!("{:?}", e);
|
||||
}
|
||||
patches
|
||||
}
|
||||
}
|
||||
|
|
@ -84,6 +84,7 @@ impl<'a> Executor<'a> {
|
|||
|
||||
on!(plugin);
|
||||
on!(plugin_do);
|
||||
on!(update_progress);
|
||||
on!(stop);
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +193,6 @@ impl<'a> Executor<'a> {
|
|||
};
|
||||
}
|
||||
|
||||
on!(update);
|
||||
on!(open);
|
||||
on!(toggle, "close");
|
||||
on!(arrow);
|
||||
|
|
|
|||
|
|
@ -54,4 +54,20 @@ impl Lives {
|
|||
error!("{e}");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn partial_scope<'a>(cx: &'a Ctx, f: impl FnOnce(&Scope<'a, 'a>)) {
|
||||
let result = LUA.scope(|scope| {
|
||||
LUA.globals().set(
|
||||
"cx",
|
||||
LUA.create_table_from([("tasks", super::Tasks::new(scope, &cx.tasks).make()?)])?,
|
||||
)?;
|
||||
|
||||
f(scope);
|
||||
Ok(())
|
||||
});
|
||||
|
||||
if let Err(e) = result {
|
||||
error!("{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
45
yazi-plugin/preset/components/progress.lua
Normal file
45
yazi-plugin/preset/components/progress.lua
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
Progress = {
|
||||
area = ui.Rect.default,
|
||||
}
|
||||
|
||||
function Progress:render(area, offset)
|
||||
self.area = ui.Rect {
|
||||
x = math.max(0, area.w - offset - 21),
|
||||
y = area.y,
|
||||
w = math.max(0, math.min(20, area.w - offset - 1)),
|
||||
h = 1,
|
||||
}
|
||||
return self:partial_render()
|
||||
end
|
||||
|
||||
-- Progress bars usually need frequent updates to report the latest task progress.
|
||||
-- We use `partial_render()` to partially render it when there is progress change,
|
||||
-- which has almost no cost compared to a full render by `render()`.
|
||||
--
|
||||
-- However, at this time, we can only access `cx.tasks`. If you need certain data from the complete `cx`,
|
||||
-- just cache it to `self` during `render()`, and read it in `partial_render()` - this process is referred to as "composition".
|
||||
function Progress:partial_render()
|
||||
local progress = cx.tasks.progress
|
||||
if progress.total == 0 then
|
||||
return { ui.Paragraph(self.area, {}) }
|
||||
end
|
||||
|
||||
local gauge = ui.Gauge(self.area)
|
||||
if progress.fail == 0 then
|
||||
gauge = gauge:gauge_style(THEME.status.progress_normal)
|
||||
else
|
||||
gauge = gauge:gauge_style(THEME.status.progress_error)
|
||||
end
|
||||
|
||||
local percent = 99
|
||||
if progress.found ~= 0 then
|
||||
percent = math.min(99, ya.round(progress.processed * 100 / progress.found))
|
||||
end
|
||||
|
||||
local left = progress.total - progress.succ
|
||||
return {
|
||||
gauge
|
||||
:percent(percent)
|
||||
:label(ui.Span(string.format("%3d%%, %d left", percent, left)):style(THEME.status.progress_label)),
|
||||
}
|
||||
end
|
||||
|
|
@ -108,47 +108,14 @@ function Status:position()
|
|||
}
|
||||
end
|
||||
|
||||
function Status:progress(area, offset)
|
||||
local progress = cx.tasks.progress
|
||||
local left = progress.total - progress.succ
|
||||
if left == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
local gauge = ui.Gauge(ui.Rect {
|
||||
x = math.max(0, area.w - offset - 21),
|
||||
y = area.y,
|
||||
w = math.max(0, math.min(20, area.w - offset - 1)),
|
||||
h = 1,
|
||||
})
|
||||
|
||||
if progress.fail == 0 then
|
||||
gauge = gauge:gauge_style(THEME.status.progress_normal)
|
||||
else
|
||||
gauge = gauge:gauge_style(THEME.status.progress_error)
|
||||
end
|
||||
|
||||
local percent = 99
|
||||
if progress.found ~= 0 then
|
||||
percent = math.min(99, progress.processed * 100 / progress.found)
|
||||
end
|
||||
|
||||
return {
|
||||
gauge
|
||||
:percent(percent)
|
||||
:label(ui.Span(string.format("%3d%%, %d left", percent, left)):style(THEME.status.progress_label)),
|
||||
}
|
||||
end
|
||||
|
||||
function Status:render(area)
|
||||
self.area = area
|
||||
|
||||
local left = ui.Line { self:mode(), self:size(), self:name() }
|
||||
local right = ui.Line { self:permissions(), self:percentage(), self:position() }
|
||||
local progress = self:progress(area, right:width())
|
||||
return {
|
||||
ui.Paragraph(area, { left }),
|
||||
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
||||
table.unpack(progress),
|
||||
table.unpack(Progress:render(area, right:width())),
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ local M = {}
|
|||
|
||||
function M:peek()
|
||||
local url = ya.file_cache(self)
|
||||
if not url or not fs.symlink_metadata(url) then
|
||||
if not url or not fs.cha(url) then
|
||||
url = self.file.url
|
||||
end
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ function M:seek() end
|
|||
|
||||
function M:preload()
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache or fs.symlink_metadata(cache) then
|
||||
if not cache or fs.cha(cache) then
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ end
|
|||
|
||||
function M:preload()
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache or fs.symlink_metadata(cache) then
|
||||
if not cache or fs.cha(cache) then
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function M:preload()
|
|||
end
|
||||
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache or fs.symlink_metadata(cache) then
|
||||
if not cache or fs.cha(cache) then
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ function ya.clamp(min, x, max)
|
|||
end
|
||||
end
|
||||
|
||||
function ya.round(x) return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5) end
|
||||
|
||||
function ya.flat(t)
|
||||
local r = {}
|
||||
for _, v in ipairs(t) do
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ impl UserData for Bar {
|
|||
}
|
||||
|
||||
impl Renderable for Bar {
|
||||
fn area(&self) -> ratatui::layout::Rect { self.area }
|
||||
|
||||
fn render(self: Box<Self>, buf: &mut ratatui::buffer::Buffer) {
|
||||
if self.area.area() == 0 {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ impl UserData for Border {
|
|||
}
|
||||
|
||||
impl Renderable for Border {
|
||||
fn area(&self) -> ratatui::layout::Rect { self.area }
|
||||
|
||||
fn render(self: Box<Self>, buf: &mut ratatui::buffer::Buffer) {
|
||||
let mut block =
|
||||
ratatui::widgets::Block::default().borders(self.position).border_type(self.type_);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ pub fn init(lua: &Lua) -> mlua::Result<()> {
|
|||
}
|
||||
|
||||
pub trait Renderable {
|
||||
fn area(&self) -> ratatui::layout::Rect;
|
||||
|
||||
fn render(self: Box<Self>, buf: &mut ratatui::buffer::Buffer);
|
||||
|
||||
fn clone_render(&self, buf: &mut ratatui::buffer::Buffer);
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ impl UserData for Gauge {
|
|||
}
|
||||
|
||||
impl Renderable for Gauge {
|
||||
fn area(&self) -> ratatui::layout::Rect { self.area }
|
||||
|
||||
fn render(self: Box<Self>, buf: &mut ratatui::buffer::Buffer) {
|
||||
let mut gauge = ratatui::widgets::Gauge::default();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ impl List {
|
|||
impl UserData for List {}
|
||||
|
||||
impl Renderable for List {
|
||||
fn area(&self) -> ratatui::layout::Rect { self.area }
|
||||
|
||||
fn render(self: Box<Self>, buf: &mut ratatui::buffer::Buffer) {
|
||||
self.inner.render(self.area, buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ impl UserData for Paragraph {
|
|||
}
|
||||
|
||||
impl Renderable for Paragraph {
|
||||
fn area(&self) -> ratatui::layout::Rect { self.area }
|
||||
|
||||
fn render(self: Box<Self>, buf: &mut ratatui::buffer::Buffer) {
|
||||
let mut p = ratatui::widgets::Paragraph::new(self.text);
|
||||
if let Some(style) = self.style {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::Lua;
|
||||
use mlua::{IntoLua, Lua, Value};
|
||||
use tokio::fs;
|
||||
|
||||
use crate::bindings::{Cast, Cha, UrlRef};
|
||||
|
|
@ -9,20 +9,29 @@ pub fn install(lua: &Lua) -> mlua::Result<()> {
|
|||
lua.create_table_from([
|
||||
(
|
||||
"write",
|
||||
lua.create_async_function(|_, (url, data): (UrlRef, mlua::String)| async move {
|
||||
Ok(fs::write(&*url, data).await.is_ok())
|
||||
lua.create_async_function(|lua, (url, data): (UrlRef, mlua::String)| async move {
|
||||
Ok(match fs::write(&*url, data).await {
|
||||
Ok(_) => (Value::Boolean(true), Value::Nil),
|
||||
Err(e) => (Value::Boolean(false), e.raw_os_error().into_lua(lua)?),
|
||||
})
|
||||
})?,
|
||||
),
|
||||
(
|
||||
"metadata",
|
||||
"cha",
|
||||
lua.create_async_function(|lua, url: UrlRef| async move {
|
||||
fs::metadata(&*url).await.ok().map(|m| Cha::cast(lua, m)).transpose()
|
||||
Ok(match fs::symlink_metadata(&*url).await {
|
||||
Ok(m) => (Cha::cast(lua, m)?.into_lua(lua)?, Value::Nil),
|
||||
Err(e) => (Value::Nil, e.raw_os_error().into_lua(lua)?),
|
||||
})
|
||||
})?,
|
||||
),
|
||||
(
|
||||
"symlink_metadata",
|
||||
"cha_follow",
|
||||
lua.create_async_function(|lua, url: UrlRef| async move {
|
||||
fs::symlink_metadata(&*url).await.ok().map(|m| Cha::cast(lua, m)).transpose()
|
||||
Ok(match fs::metadata(&*url).await {
|
||||
Ok(m) => (Cha::cast(lua, m)?.into_lua(lua)?, Value::Nil),
|
||||
Err(e) => (Value::Nil, e.raw_os_error().into_lua(lua)?),
|
||||
})
|
||||
})?,
|
||||
),
|
||||
])?,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ pub fn init() {
|
|||
lua.load(include_str!("../preset/components/manager.lua")).exec()?;
|
||||
lua.load(include_str!("../preset/components/parent.lua")).exec()?;
|
||||
lua.load(include_str!("../preset/components/preview.lua")).exec()?;
|
||||
lua.load(include_str!("../preset/components/progress.lua")).exec()?;
|
||||
lua.load(include_str!("../preset/components/status.lua")).exec()?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::{ffi::OsStr, sync::Arc, time::Duration};
|
||||
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use parking_lot::RwLock;
|
||||
use parking_lot::Mutex;
|
||||
use tokio::{fs, select, sync::{mpsc::{self, UnboundedReceiver}, oneshot}};
|
||||
use yazi_config::{open::Opener, plugin::PluginRule, TASKS};
|
||||
use yazi_shared::{emit, event::Exec, fs::{unique_path, Url}, Layer, Throttle};
|
||||
|
|
@ -17,7 +17,7 @@ pub struct Scheduler {
|
|||
|
||||
micro: async_priority_channel::Sender<BoxFuture<'static, ()>, u8>,
|
||||
prog: mpsc::UnboundedSender<TaskProg>,
|
||||
pub running: Arc<RwLock<Running>>,
|
||||
pub running: Arc<Mutex<Running>>,
|
||||
}
|
||||
|
||||
impl Scheduler {
|
||||
|
|
@ -77,7 +77,7 @@ impl Scheduler {
|
|||
}
|
||||
Ok((op, _)) = macro_.recv() => {
|
||||
let id = op.id();
|
||||
if !running.read().exists(id) {
|
||||
if !running.lock().exists(id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -104,13 +104,13 @@ impl Scheduler {
|
|||
while let Some(op) = rx.recv().await {
|
||||
match op {
|
||||
TaskProg::New(id, size) => {
|
||||
if let Some(task) = running.write().get_mut(id) {
|
||||
if let Some(task) = running.lock().get_mut(id) {
|
||||
task.total += 1;
|
||||
task.found += size;
|
||||
}
|
||||
}
|
||||
TaskProg::Adv(id, succ, processed) => {
|
||||
let mut running = running.write();
|
||||
let mut running = running.lock();
|
||||
if let Some(task) = running.get_mut(id) {
|
||||
task.succ += succ;
|
||||
task.processed += processed;
|
||||
|
|
@ -122,12 +122,12 @@ impl Scheduler {
|
|||
}
|
||||
}
|
||||
TaskProg::Succ(id) => {
|
||||
if let Some(fut) = running.write().try_remove(id, TaskStage::Dispatched) {
|
||||
if let Some(fut) = running.lock().try_remove(id, TaskStage::Dispatched) {
|
||||
micro.try_send(fut, NORMAL).ok();
|
||||
}
|
||||
}
|
||||
TaskProg::Fail(id, reason) => {
|
||||
if let Some(task) = running.write().get_mut(id) {
|
||||
if let Some(task) = running.lock().get_mut(id) {
|
||||
task.fail += 1;
|
||||
task.logs.push_str(&reason);
|
||||
task.logs.push('\n');
|
||||
|
|
@ -138,7 +138,7 @@ impl Scheduler {
|
|||
}
|
||||
}
|
||||
TaskProg::Log(id, line) => {
|
||||
if let Some(task) = running.write().get_mut(id) {
|
||||
if let Some(task) = running.lock().get_mut(id) {
|
||||
task.logs.push_str(&line);
|
||||
task.logs.push('\n');
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ impl Scheduler {
|
|||
}
|
||||
|
||||
pub fn cancel(&self, id: usize) -> bool {
|
||||
let mut running = self.running.write();
|
||||
let mut running = self.running.lock();
|
||||
let b = running.all.remove(&id).is_some();
|
||||
|
||||
if let Some(hook) = running.hooks.remove(&id) {
|
||||
|
|
@ -176,7 +176,7 @@ impl Scheduler {
|
|||
}
|
||||
|
||||
pub fn file_cut(&self, from: Url, mut to: Url, force: bool) {
|
||||
let mut running = self.running.write();
|
||||
let mut running = self.running.lock();
|
||||
let id = running.add(TaskKind::User, format!("Cut {:?} to {:?}", from, to));
|
||||
|
||||
running.hooks.insert(id, {
|
||||
|
|
@ -188,7 +188,7 @@ impl Scheduler {
|
|||
if !canceled {
|
||||
File::remove_empty_dirs(&from).await;
|
||||
}
|
||||
running.write().try_remove(id, TaskStage::Hooked);
|
||||
running.lock().try_remove(id, TaskStage::Hooked);
|
||||
}
|
||||
.boxed()
|
||||
})
|
||||
|
|
@ -209,7 +209,7 @@ impl Scheduler {
|
|||
|
||||
pub fn file_copy(&self, from: Url, mut to: Url, force: bool, follow: bool) {
|
||||
let name = format!("Copy {:?} to {:?}", from, to);
|
||||
let id = self.running.write().add(TaskKind::User, name);
|
||||
let id = self.running.lock().add(TaskKind::User, name);
|
||||
|
||||
let file = self.file.clone();
|
||||
_ = self.micro.try_send(
|
||||
|
|
@ -226,7 +226,7 @@ impl Scheduler {
|
|||
|
||||
pub fn file_link(&self, from: Url, mut to: Url, relative: bool, force: bool) {
|
||||
let name = format!("Link {from:?} to {to:?}");
|
||||
let id = self.running.write().add(TaskKind::User, name);
|
||||
let id = self.running.lock().add(TaskKind::User, name);
|
||||
|
||||
let file = self.file.clone();
|
||||
_ = self.micro.try_send(
|
||||
|
|
@ -245,7 +245,7 @@ impl Scheduler {
|
|||
}
|
||||
|
||||
pub fn file_delete(&self, target: Url) {
|
||||
let mut running = self.running.write();
|
||||
let mut running = self.running.lock();
|
||||
let id = running.add(TaskKind::User, format!("Delete {:?}", target));
|
||||
|
||||
running.hooks.insert(id, {
|
||||
|
|
@ -257,7 +257,7 @@ impl Scheduler {
|
|||
if !canceled {
|
||||
fs::remove_dir_all(target).await.ok();
|
||||
}
|
||||
running.write().try_remove(id, TaskStage::Hooked);
|
||||
running.lock().try_remove(id, TaskStage::Hooked);
|
||||
}
|
||||
.boxed()
|
||||
})
|
||||
|
|
@ -275,7 +275,7 @@ impl Scheduler {
|
|||
|
||||
pub fn file_trash(&self, target: Url) {
|
||||
let name = format!("Trash {:?}", target);
|
||||
let id = self.running.write().add(TaskKind::User, name);
|
||||
let id = self.running.lock().add(TaskKind::User, name);
|
||||
|
||||
let file = self.file.clone();
|
||||
_ = self.micro.try_send(
|
||||
|
|
@ -288,7 +288,7 @@ impl Scheduler {
|
|||
}
|
||||
|
||||
pub fn plugin_micro(&self, name: String) {
|
||||
let id = self.running.write().add(TaskKind::User, format!("Run micro plugin `{name}`"));
|
||||
let id = self.running.lock().add(TaskKind::User, format!("Run micro plugin `{name}`"));
|
||||
|
||||
let plugin = self.plugin.clone();
|
||||
_ = self.micro.try_send(
|
||||
|
|
@ -301,13 +301,13 @@ impl Scheduler {
|
|||
}
|
||||
|
||||
pub fn plugin_macro(&self, name: String) {
|
||||
let id = self.running.write().add(TaskKind::User, format!("Run macro plugin `{name}`"));
|
||||
let id = self.running.lock().add(TaskKind::User, format!("Run macro plugin `{name}`"));
|
||||
|
||||
self.plugin.macro_(PluginOpEntry { id, name }).ok();
|
||||
}
|
||||
|
||||
pub fn preload_paged(&self, rule: &PluginRule, targets: Vec<&yazi_shared::fs::File>) {
|
||||
let id = self.running.write().add(
|
||||
let id = self.running.lock().add(
|
||||
TaskKind::Preload,
|
||||
format!("Run preloader `{}` with {} target(s)", rule.exec.cmd, targets.len()),
|
||||
);
|
||||
|
|
@ -326,7 +326,7 @@ impl Scheduler {
|
|||
|
||||
pub fn preload_size(&self, targets: Vec<&Url>) {
|
||||
let throttle = Arc::new(Throttle::new(targets.len(), Duration::from_millis(300)));
|
||||
let mut running = self.running.write();
|
||||
let mut running = self.running.lock();
|
||||
|
||||
for target in targets {
|
||||
let id = running.add(TaskKind::Preload, format!("Calculate the size of {:?}", target));
|
||||
|
|
@ -351,7 +351,7 @@ impl Scheduler {
|
|||
if args.is_empty() { s } else { format!("{s} with `{args}`") }
|
||||
};
|
||||
|
||||
let mut running = self.running.write();
|
||||
let mut running = self.running.lock();
|
||||
let id = running.add(TaskKind::User, name);
|
||||
|
||||
let (cancel_tx, mut cancel_rx) = oneshot::channel();
|
||||
|
|
@ -362,7 +362,7 @@ impl Scheduler {
|
|||
if canceled {
|
||||
cancel_rx.close();
|
||||
}
|
||||
running.write().try_remove(id, TaskStage::Hooked);
|
||||
running.lock().try_remove(id, TaskStage::Hooked);
|
||||
}
|
||||
.boxed()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ pub fn copy_with_progress(from: &Path, to: &Path) -> mpsc::Receiver<Result<u64,
|
|||
select! {
|
||||
res = &mut tick_rx => exit = Some(res.unwrap()),
|
||||
_ = tx.closed() => break,
|
||||
_ = time::sleep(time::Duration::from_secs(1)) => (),
|
||||
_ = time::sleep(time::Duration::from_secs(3)) => (),
|
||||
}
|
||||
|
||||
match exit {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue