mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: incomplete cache calculation algorithm (#2922)
This commit is contained in:
parent
9d05946f4b
commit
2d1cf621db
7 changed files with 38 additions and 20 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -1042,9 +1042,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.13.2"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcc37f9a2bfe731e69f1e08d29d91d30604b9ce24bcb2880a961e82d89c6ed89"
|
||||
checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ impl Brand {
|
|||
("WezTerm", Self::WezTerm),
|
||||
("foot", Self::Foot),
|
||||
("ghostty", Self::Ghostty),
|
||||
("Warp", Self::Warp),
|
||||
("tmux ", Self::Tmux),
|
||||
("libvterm", Self::VTerm),
|
||||
("Bobcat", Self::Bobcat),
|
||||
|
|
|
|||
|
|
@ -44,17 +44,7 @@ impl File {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hash_u64(&self) -> u64 {
|
||||
let mut h = foldhash::fast::FixedState::default().build_hasher();
|
||||
self.url.hash(&mut h);
|
||||
h.write_u8(0);
|
||||
self.cha.len.hash(&mut h);
|
||||
h.write_u8(0);
|
||||
self.cha.mtime.hash(&mut h);
|
||||
h.write_u8(0);
|
||||
self.cha.btime.hash(&mut h);
|
||||
h.finish()
|
||||
}
|
||||
pub fn hash_u64(&self) -> u64 { foldhash::fast::FixedState::default().hash_one(self) }
|
||||
|
||||
#[inline]
|
||||
pub fn rebase(&self, parent: &Url) -> Self {
|
||||
|
|
@ -79,3 +69,12 @@ impl File {
|
|||
#[inline]
|
||||
pub fn stem(&self) -> Option<&OsStr> { self.url.file_stem() }
|
||||
}
|
||||
|
||||
impl Hash for File {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.url.hash(state);
|
||||
self.cha.len.hash(state);
|
||||
self.cha.btime.hash(state);
|
||||
self.cha.mtime.hash(state);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ function M:entry(job)
|
|||
end
|
||||
|
||||
local value, event = ya.input {
|
||||
pos = { "center", w = 50 },
|
||||
title = string.format('Password for "%s":', from.name),
|
||||
obscure = true,
|
||||
position = { "center", w = 50 },
|
||||
}
|
||||
if event == 1 then
|
||||
pwd = value
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ mod macros;
|
|||
|
||||
yazi_macro::mod_pub!(bindings config elements external file fs isolate loader process pubsub utils);
|
||||
|
||||
yazi_macro::mod_flat!(clipboard composer lua runtime);
|
||||
yazi_macro::mod_flat!(clipboard composer lua runtime twox);
|
||||
|
||||
pub fn init() -> anyhow::Result<()> {
|
||||
CLIPBOARD.with(<_>::default);
|
||||
|
|
|
|||
17
yazi-plugin/src/twox.rs
Normal file
17
yazi-plugin/src/twox.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use std::hash::Hasher;
|
||||
|
||||
pub struct Twox128(twox_hash::XxHash3_128);
|
||||
|
||||
impl Default for Twox128 {
|
||||
fn default() -> Self { Self(twox_hash::XxHash3_128::new()) }
|
||||
}
|
||||
|
||||
impl Twox128 {
|
||||
pub fn finish_128(self) -> u128 { self.0.finish_128() }
|
||||
}
|
||||
|
||||
impl Hasher for Twox128 {
|
||||
fn write(&mut self, bytes: &[u8]) { self.0.write(bytes) }
|
||||
|
||||
fn finish(&self) -> u64 { unreachable!() }
|
||||
}
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use mlua::{Function, Lua, Table};
|
||||
use twox_hash::XxHash3_128;
|
||||
use yazi_binding::Url;
|
||||
use yazi_config::YAZI;
|
||||
|
||||
use super::Utils;
|
||||
use crate::file::FileRef;
|
||||
use crate::{Twox128, file::FileRef};
|
||||
|
||||
impl Utils {
|
||||
pub(super) fn file_cache(lua: &Lua) -> mlua::Result<Function> {
|
||||
|
|
@ -15,9 +16,9 @@ impl Utils {
|
|||
}
|
||||
|
||||
let hex = {
|
||||
let mut h = XxHash3_128::new();
|
||||
h.write(file.url.as_os_str().as_encoded_bytes());
|
||||
h.write(format!("//{:?}//{}", file.cha.mtime, t.raw_get("skip").unwrap_or(0)).as_bytes());
|
||||
let mut h = Twox128::default();
|
||||
file.hash(&mut h);
|
||||
t.raw_get("skip").unwrap_or(0usize).hash(&mut h);
|
||||
format!("{:x}", h.finish_128())
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue