ronantakizawa/codereview-bench huggingface dataset:
Repository: sxyazi/yazi
File: yazi-plugin/preset/components/tasks.lua (Lua)

Code before:
Tasks = {
	_id = "tasks",
}

function Tasks:new(area) return setmetatable({ _area = area }, { __index = self }) end

function Tasks:reflow() return { self } end

function Tasks:redraw()
	local rows = {}
	for _, snap in ipairs(cx.tasks.snaps) do
		rows[#rows + 1] = ui.Row { snap.name }
	end

	local tbl = ui.Table(rows)
		:area(self._area:pad(ui.Pad.x(1)))
		:row(cx.tasks.cursor)
		:row_style(th.tasks.hovered)
		:widths { ui.Constraint.Fill(1) }

	return { tbl }
end


Review comment (refactor):
The magic number `3` representing lines per task should be extracted as a constant to match the corresponding change in the Rust code and improve maintainability.

Code after:
	_id = "tasks",
}

function Tasks:new(area)
	local me = setmetatable({ _area = area }, { __index = self })
	me:layout()
	return me
end

function Tasks:layout()
	self._area = self._area:pad(ui.Pad(1, 1, 1, 3))
	self._chunks = ui.Layout()
		:direction(ui.Layout.HORIZONTAL)
		:constraints({
			ui.Constraint.Percentage(60),
			ui.Constraint.Percentage(40),
		})
		:split(self._area)
end

function Tasks:reflow() return { self } end

function Tasks:redraw()
	local elements = {}
	for i, snap in ipairs(cx.tasks.snaps) do
		local y = self._area.y + (i - 1) * 3
		if y >= self._area.bottom then
			break
		end

		elements[#elements + 1] = ui.Line({ self:icon(snap), snap.name }):area(ui.Rect {
			x = self._area.x,
			y = y,
			w = self._area.w,
			h = 1,
		})

		if i == cx.tasks.cursor + 1 then
			elements[#elements] = elements[#elements]:style(th.tasks.hovered)
		end

		for _, e in ipairs(self:progress_redraw(snap, y + 1)) do
			elements[#elements + 1] = e
		end

		elements[#elements + 1] = ui.Bar(ui.Edge.LEFT)
			:area(ui.Rect {
				x = math.max(0, self._area.x - 2),
				y = y,
				w = self._area.w,
				h = 2,
Repository: sxyazi/yazi
File: yazi-fs/src/provider/local/casefold.rs (Rust)

Code before:

#[cfg(target_os = "windows")]
fn final_path(path: &Path) -> io::Result<PathBuf> {
	use std::{ffi::OsString, os::windows::{ffi::OsStringExt, fs::OpenOptionsExt, io::AsRawHandle}};

	use windows_sys::Win32::{Foundation::HANDLE, Storage::FileSystem::{FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, GetFinalPathNameByHandleW, VOLUME_NAME_DOS}};

	let file = std::fs::OpenOptions::new()
		.access_mode(0)
		.custom_flags(FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT)
		.open(path)?;

	let mut buf = [0u16; 512];
	let len = unsafe {
		GetFinalPathNameByHandleW(
			file.as_raw_handle() as HANDLE,
			buf.as_mut_ptr(),
			buf.len() as u32,
			VOLUME_NAME_DOS,
		)
	};

	if len == 0 {
		Err(io::Error::last_os_error())
	} else if len as usize > buf.len() {
		Err(io::Error::new(io::ErrorKind::Other, "Path too long"))
	} else if buf.starts_with(&[92, 92, 63, 92]) {
		Ok(PathBuf::from(OsString::from_wide(&buf[4..len as usize])))
	} else {
		Ok(PathBuf::from(OsString::from_wide(&buf[0..len as usize])))
	}
}


Review comment (bug):
The error message 'Path too long' could be more informative. Consider including the actual path length and buffer size limit, e.g., 'Path length ({len}) exceeds buffer size ({})' to help with debugging.
```suggestion
		Err(io::Error::new(
			io::ErrorKind::Other,
			format!("Path length ({}) exceeds buffer size ({})", len, buf.len()),
		))
```

Code after:

#[cfg(target_os = "windows")]
fn final_path(path: &Path) -> io::Result<PathBuf> {
	use std::{ffi::OsString, fs::File, os::windows::{ffi::OsStringExt, fs::OpenOptionsExt, io::AsRawHandle}};

	use windows_sys::Win32::{Foundation::HANDLE, Storage::FileSystem::{FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, GetFinalPathNameByHandleW, VOLUME_NAME_DOS}};
	use yazi_shared::Either;

	let file = std::fs::OpenOptions::new()
		.access_mode(0)
		.custom_flags(FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT)
		.open(path)?;

	fn inner(file: &File, buf: &mut [u16]) -> io::Result<Either<PathBuf, u32>> {
		let len = unsafe {
			GetFinalPathNameByHandleW(
				file.as_raw_handle() as HANDLE,
				buf.as_mut_ptr(),
				buf.len() as u32,
				VOLUME_NAME_DOS,
			)
		};

		Ok(if len == 0 {
			Err(io::Error::last_os_error())?
		} else if len as usize > buf.len() {
			Either::Right(len)
		} else if buf.starts_with(&[92, 92, 63, 92]) {
			Either::Left(PathBuf::from(OsString::from_wide(&buf[4..len as usize])))
		} else {
			Either::Left(PathBuf::from(OsString::from_wide(&buf[0..len as usize])))
		})
	}

	match inner(&file, &mut [0u16; 512])? {
		Either::Left(path) => Ok(path),
		Either::Right(len) => {
			let mut buf = vec![0u16; len as usize];
			inner(&file, &mut buf)?
				.left_or_err(|| io::Error::new(io::ErrorKind::InvalidData, "path too long"))
		}
	}
}
Repository: sxyazi/yazi
File: yazi-actor/src/mgr/open.rs (Rust)

Code before:
				}
			})
			.collect();

		let cwd = cx.cwd().clone();
		if todo.is_empty() {
			return act!(mgr:open_do, cx, OpenDoOpt { cwd, hovered, targets, interactive: opt.interactive });
		}

		tokio::spawn(async move {
			let mut files = Vec::with_capacity(todo.len());
			for i in todo {
				if let Ok(f) = File::new(&targets[i].0).await {
					files.push(f);
				}
			}

			for (fetcher, files) in YAZI.plugin.mime_fetchers(files) {
				if let Err(e) = isolate::fetch(CmdCow::from(&fetcher.run), files).await {
					error!("Fetch mime failed on opening: {e}");
				}
			}

			MgrProxy::open_do(OpenDoOpt { cwd, hovered, targets, interactive: opt.interactive });
		});
		succ!();
	}
}

// --- Do
pub struct OpenDo;

impl Actor for OpenDo {
	type Options = OpenDoOpt;

	const NAME: &str = "open_do";

	fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data> {
		let mut targets = opt.targets;
		targets.iter_mut().filter(|(_, m)| m.is_empty()).for_each(|(u, m)| {
			*m = cx.mgr.mimetype.by_url(u).unwrap_or_default();
		});

		targets.retain(|(_, m)| !m.is_empty());
		if targets.is_empty() {
			succ!();
		} else if !opt.interactive {
			succ!(cx.tasks.process_from_files(opt.cwd, opt.hovered, targets));
		}

		let openers: Vec<_> = YAZI.opener.all(YAZI.open.common(&targets).into_iter());

Review comment (suggestion):
The double negation `!canceled` within `!rx.await.is_ok_and()` creates confusing logic. Consider using `rx.await.is_err_or(|canceled| canceled)` for better readability.
```suggestion
				if rx.await.is_err_or(|canceled| canceled) {
```

Code after:
			})
			.collect();

		let cwd = cx.cwd().clone();
		if todo.is_empty() {
			return act!(mgr:open_do, cx, OpenDoOpt { cwd, hovered, targets, interactive: opt.interactive });
		}

		let scheduler = cx.tasks.scheduler.clone();
		tokio::spawn(async move {
			let mut files = Vec::with_capacity(todo.len());
			for i in todo {
				if let Ok(f) = File::new(&targets[i].0).await {
					files.push(f);
				}
			}

			let mut wg = vec![];
			for (fetcher, files) in YAZI.plugin.mime_fetchers(files) {
				let (tx, rx) = oneshot::channel();
				scheduler.fetch_paged(fetcher, files, Some(tx));
				wg.push(rx);
			}

			for rx in wg {
				if !rx.await.is_ok_and(|canceled| !canceled) {
					return;
				}
			}

			MgrProxy::open_do(OpenDoOpt { cwd, hovered, targets, interactive: opt.interactive });
		});
		succ!();
	}
}

// --- Do
pub struct OpenDo;

impl Actor for OpenDo {
	type Options = OpenDoOpt;

	const NAME: &str = "open_do";

	fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data> {
		let mut targets = opt.targets;
		targets.iter_mut().filter(|(_, m)| m.is_empty()).for_each(|(u, m)| {
			*m = cx.mgr.mimetype.by_url(u).unwrap_or_default();
		});

		targets.retain(|(_, m)| !m.is_empty());
Repository: sxyazi/yazi
File: yazi-fs/src/cha/mode.rs (Rust)

Code before:
		};

		s
	}

	pub(super) fn from_bare(r#type: ChaType) -> Self {
		match r#type {
			ChaType::File => Self::T_FILE,
			ChaType::Dir => Self::T_DIR,
			ChaType::Link => Self::T_LINK,
			ChaType::Block => Self::T_BLOCK,
			ChaType::Char => Self::T_CHAR,
			ChaType::Sock => Self::T_SOCK,
			ChaType::FIFO => Self::T_FIFO,
			ChaType::Unknown => Self::empty(),
		}
	}
}

impl ChaMode {
	// TODO: deprecate
	#[inline]
	pub fn is_exec(self) -> bool { self.contains(Self::U_EXEC) }

	#[inline]
	pub fn is_sticky(self) -> bool { self.contains(Self::S_STICKY) }
}


Review comment (performance):
[nitpick] These methods changed from `const fn` to regular `fn` without justification. If there's no specific reason they need to be non-const, consider keeping them as `const fn` for better performance and compile-time evaluation.

Code after:
		};

		s
	}

	pub(super) fn from_bare(r#type: ChaType) -> Self {
		match r#type {
			ChaType::File => Self::T_FILE,
			ChaType::Dir => Self::T_DIR,
			ChaType::Link => Self::T_LINK,
			ChaType::Block => Self::T_BLOCK,
			ChaType::Char => Self::T_CHAR,
			ChaType::Sock => Self::T_SOCK,
			ChaType::FIFO => Self::T_FIFO,
			ChaType::Unknown => Self::empty(),
		}
	}
}

impl ChaMode {
	// TODO: deprecate
	#[inline]
	pub const fn is_exec(self) -> bool { self.contains(Self::U_EXEC) }

	#[inline]
	pub const fn is_sticky(self) -> bool { self.contains(Self::S_STICKY) }
}
Repository: sxyazi/yazi
File: yazi-plugin/preset/plugins/svg.lua (Lua)

Code before:
	if not child then
		return true, Err("Failed to start `resvg`, error: %s", err)
	end

	local status, err
	while true do
		ya.sleep(0.2)

		status, err = child:try_wait()
		if status or err then
			break
		end

		local id, mem = child:id(), nil
		if id then
			mem = ya.proc_info(id).mem_resident
		end
		if mem and mem > rt.tasks.image_alloc then
			child:start_kill()
			err = Err("memory limit exceeded, pid: %s, memory: %s", id, mem)
			break
		end
	end

	if not status then
		return true, Err("Error while running `resvg`: %s", err)
	elseif not status.success then
		return false, Err("`resvg` exited with error code: %s", status.code)
	else
		return true
	end
end

function M:spot(job) require("file"):spot(job) end

return M


Review comment (bug):
The removed `break` statement was necessary to exit the loop when memory limit is exceeded. Without it, the loop will continue running even after killing the child process, potentially causing unnecessary processing and incorrect behavior.
```suggestion
			err = Err("memory limit exceeded, pid: %s, memory: %s", id, mem)
			break
```

Code after:

	local child, err = cmd:arg({ tostring(job.file.url), tostring(cache) }):spawn()
	if not child then
		return true, Err("Failed to start `resvg`, error: %s", err)
	end

	local status, err
	if rt.tasks.image_alloc == 0 then
		status, err = child:wait()
	end

	while not status and not err do
		ya.sleep(0.2)

		status, err = child:try_wait()
		if status or err then
			break
		end

		local id, mem = child:id(), nil
		if id then
			mem = ya.proc_info(id).mem_resident
		end
		if mem and mem > rt.tasks.image_alloc then
			child:start_kill()
			err = Err("memory limit exceeded, pid: %s, memory: %s", id, mem)
		end
	end

	if not status then
		return true, Err("Error while running `resvg`: %s", err)
	elseif not status.success then
		return false, Err("`resvg` exited with error code: %s", status.code)
	else
		return true
	end
end

function M:spot(job) require("file"):spot(job) end

return M
Repository: sxyazi/yazi
File: yazi-plugin/preset/plugins/svg.lua (Lua)

Code before:
		return true
	end

	-- stylua: ignore
	local cmd = Command("resvg"):arg {
		"-w", rt.preview.max_width, "-h", rt.preview.max_height,
		"--image-rendering", "optimizeSpeed",
		tostring(job.file.url), tostring(cache)
	}
	if rt.tasks.image_alloc > 0 then
		cmd = cmd:memory(rt.tasks.image_alloc)
	end

	local child, err = cmd:spawn()
	if not child then
		return true, Err("Failed to start `resvg`, error: %s", err)
	end

	local status, err
	while true do
		ya.sleep(0.2)

		status, err = child:try_wait()
		if status or err then
			break
		end

		local id, mem = child:id(), nil
		if id then
			mem = ya.proc_info(id).mem_resident
		end
		if mem and mem > rt.tasks.image_alloc then
			child:start_kill()
			err = Err("memory limit exceeded, pid: %s, memory: %s", id, mem)
			break
		end
	end

	if not status then
		return true, Err("Error while running `resvg`: %s", err)
	elseif not status.success then
		return false, Err("`resvg` exited with error code: %s", status.code)
	else
		return true
	end
end

function M:spot(job) require("file"):spot(job) end

return M


Review comment (performance):
The logic change introduces complexity by having two different wait patterns. When `image_alloc == 0`, the code calls `wait()` immediately, but then enters a loop that checks `not status`. This could lead to confusing control flow since `status` would already be set from the `wait()` call.

Code after:
		return true
	end

	-- stylua: ignore
	local cmd = Command("resvg"):arg {
		"-w", rt.preview.max_width, "-h", rt.preview.max_height,
		"--image-rendering", "optimizeSpeed",
	}
	if job.args.bg then
		cmd = cmd:arg { "--background", job.args.bg }
	end
	if rt.tasks.image_alloc > 0 then
		cmd = cmd:memory(rt.tasks.image_alloc)
	end

	local child, err = cmd:arg({ tostring(job.file.url), tostring(cache) }):spawn()
	if not child then
		return true, Err("Failed to start `resvg`, error: %s", err)
	end

	local status, err
	if rt.tasks.image_alloc == 0 then
		status, err = child:wait()
	end

	while not status and not err do
		ya.sleep(0.2)

		status, err = child:try_wait()
		if status or err then
			break
		end

		local id, mem = child:id(), nil
		if id then
			mem = ya.proc_info(id).mem_resident
		end
		if mem and mem > rt.tasks.image_alloc then
			child:start_kill()
			err = Err("memory limit exceeded, pid: %s, memory: %s", id, mem)
		end
	end

	if not status then
		return true, Err("Error while running `resvg`: %s", err)
	elseif not status.success then
		return false, Err("`resvg` exited with error code: %s", status.code)
	else
		return true
	end
end
Repository: sxyazi/yazi
File: yazi-plugin/src/isolate/peek.rs (Rust)

Code before:
use yazi_config::LAYOUT;
use yazi_dds::Sendable;
use yazi_parser::app::{PluginCallback, PluginOpt};
use yazi_proxy::AppProxy;
use yazi_shared::{event::Cmd, pool::Symbol};

use super::slim_lua;
use crate::loader::{LOADER, Loader};

pub fn peek(
	cmd: &'static Cmd,
	file: yazi_fs::File,
	mime: Symbol<str>,
	skip: usize,
) -> Option<CancellationToken> {
	let (id, ..) = Loader::normalize_id(&cmd.name).ok()?;

	let ct = CancellationToken::new();
	if let Some(c) = LOADER.read().get(id) {
		if c.sync_peek {
			peek_sync(cmd, file, mime, skip);
		} else {
			peek_async(cmd, file, mime, skip, ct.clone());
		}
		return Some(ct).filter(|_| !c.sync_peek);
	}

	let ct_ = ct.clone();
	tokio::spawn(async move {
		select! {
			_ = ct_.cancelled() => {},
			Ok(b) = LOADER.ensure(id, |c| c.sync_peek) => {
				if b {
					peek_sync(cmd, file, mime, skip);
				} else {
					peek_async(cmd, file, mime, skip, ct_);
				}
			},
			else => {}
		}
	});

	Some(ct)
}

fn peek_sync(cmd: &'static Cmd, file: yazi_fs::File, mime: Symbol<str>, skip: usize) {
	let cb: PluginCallback = Box::new(move |lua, plugin| {
		let job = lua.create_table_from([
			("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?),
			("args", Sendable::args_to_table_ref(lua, &cmd.args)?.into_lua(lua)?),
			("file", File::new(file).into_lua(lua)?),

Review comment (performance):
The CancellationToken is created even when we immediately return on incompatibility or take the sync path. Initialize it only in the async branch to avoid unnecessary allocation and cloning. Example: move `let ct = CancellationToken::new();` into the `else { ... }` branch before calling `peek_async` (and return it from there if applicable).

Code after:
use yazi_config::LAYOUT;
use yazi_dds::Sendable;
use yazi_parser::{app::{PluginCallback, PluginOpt}, mgr::{PreviewLock, UpdatePeekedOpt}};
use yazi_proxy::{AppProxy, MgrProxy};
use yazi_shared::{event::Cmd, pool::Symbol};

use super::slim_lua;
use crate::loader::{LOADER, Loader};

pub fn peek(
	cmd: &'static Cmd,
	file: yazi_fs::File,
	mime: Symbol<str>,
	skip: usize,
) -> Option<CancellationToken> {
	let (id, ..) = Loader::normalize_id(&cmd.name).ok()?;

	let ct = CancellationToken::new();
	if let Some(c) = LOADER.read().get(id) {
		if let Err(e) = Loader::compatible_or_error(id, c) {
			peek_error(file, mime, skip, e);
			return None;
		} else if c.sync_peek {
			peek_sync(cmd, file, mime, skip);
		} else {
			peek_async(cmd, file, mime, skip, ct.clone());
		}
		return Some(ct).filter(|_| !c.sync_peek);
	}

	let ct_ = ct.clone();
	tokio::spawn(async move {
		select! {
			_ = ct_.cancelled() => {},
			Ok(b) = LOADER.ensure(id, |c| c.sync_peek) => {
				if b {
					peek_sync(cmd, file, mime, skip);
				} else {
					peek_async(cmd, file, mime, skip, ct_);
				}
			},
			else => {}
		}
	});

	Some(ct)
}

fn peek_sync(cmd: &'static Cmd, file: yazi_fs::File, mime: Symbol<str>, skip: usize) {
	let cb: PluginCallback = Box::new(move |lua, plugin| {
		let job = lua.create_table_from([
Repository: sxyazi/yazi
File: yazi-binding/src/elements/area.rs (Rust)

Code before:

	pub fn inner(self, padding: ratatui::widgets::Padding) -> Self {
		match self {
			Self::Pos(mut pos) => {
				pos.pad += padding;
				Self::Pos(pos)
			}
			Self::Rect(rect) => Self::Rect(rect.pad(padding.into())),
		}
	}

	pub fn transform(
		self,
		f: impl FnOnce(yazi_config::popup::Position) -> ratatui::layout::Rect,
	) -> ratatui::layout::Rect {
		match self {
			Self::Pos(pos) => *Rect(f(*pos)).pad(pos.pad),
			Self::Rect(rect) => *rect,
		}
	}
}

impl From<Rect> for Area {
	fn from(rect: Rect) -> Self { Self::Rect(rect) }
}

impl TryFrom<AnyUserData> for Area {
	type Error = mlua::Error;

	fn try_from(value: AnyUserData) -> Result<Self, Self::Error> {
		Ok(if let Ok(rect) = value.borrow::<Rect>() {
			Self::Rect(*rect)
		} else if let Ok(pos) = value.borrow::<Pos>() {
			Self::Pos(*pos)
		} else {
			return Err(EXPECTED.into_lua_err());
		})
	}
}

impl FromLua for Area {
	fn from_lua(value: Value, _: &mlua::Lua) -> mlua::Result<Self> {
		match value {
			Value::UserData(ud) => Self::try_from(ud),
			_ => Err(EXPECTED.into_lua_err()),
		}
	}
}

impl IntoLua for Area {
	fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {

Review comment (suggestion):
[nitpick] Add a brief doc comment explaining why this conversion exists (e.g., to allow passing ratatui::layout::Rect directly to APIs expecting Area). This helps future readers understand the intent and usage contexts.
```suggestion

/// Allows passing `ratatui::layout::Rect` directly to APIs expecting `Area`.
```

Code after:

	pub fn inner(self, padding: ratatui::widgets::Padding) -> Self {
		match self {
			Self::Pos(mut pos) => {
				pos.pad += padding;
				Self::Pos(pos)
			}
			Self::Rect(rect) => Self::Rect(rect.pad(padding.into())),
		}
	}

	pub fn transform(
		self,
		f: impl FnOnce(yazi_config::popup::Position) -> ratatui::layout::Rect,
	) -> ratatui::layout::Rect {
		match self {
			Self::Pos(pos) => *Rect(f(*pos)).pad(pos.pad),
			Self::Rect(rect) => *rect,
		}
	}
}

impl From<Rect> for Area {
	fn from(rect: Rect) -> Self { Self::Rect(rect) }
}

impl From<ratatui::layout::Rect> for Area {
	fn from(rect: ratatui::layout::Rect) -> Self { Self::Rect(rect.into()) }
}

impl TryFrom<AnyUserData> for Area {
	type Error = mlua::Error;

	fn try_from(value: AnyUserData) -> Result<Self, Self::Error> {
		Ok(if let Ok(rect) = value.borrow::<Rect>() {
			Self::Rect(*rect)
		} else if let Ok(pos) = value.borrow::<Pos>() {
			Self::Pos(*pos)
		} else {
			return Err(EXPECTED.into_lua_err());
		})
	}
}

impl FromLua for Area {
	fn from_lua(value: Value, _: &mlua::Lua) -> mlua::Result<Self> {
		match value {
			Value::UserData(ud) => Self::try_from(ud),
			_ => Err(EXPECTED.into_lua_err()),
		}
	}
Repository: sxyazi/yazi
File: yazi-fs/src/cha/kind.rs (Rust)

Code before:
use std::{ffi::OsStr, fs::Metadata};

use bitflags::bitflags;

bitflags! {
	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
	pub struct ChaKind: u8 {
		const HIDDEN = 0b0000_0001;
		const SYSTEM = 0b0000_0010;
		const ORPHAN = 0b0000_0100;
		const DUMMY  = 0b0000_1000;
	}
}

impl ChaKind {
	#[inline]
	pub(super) fn hidden(_name: &OsStr, _meta: &Metadata) -> Self {
		let mut me = Self::empty();

		#[cfg(unix)]
		{
			use std::os::unix::ffi::OsStrExt;
			if _name.as_bytes().starts_with(b".") {
				me |= Self::HIDDEN;
			}
		}
		#[cfg(windows)]
		{
			use std::os::windows::fs::MetadataExt;

			use windows_sys::Win32::Storage::FileSystem::{FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_SYSTEM};
			if _meta.file_attributes() & FILE_ATTRIBUTE_HIDDEN != 0 {
				me |= Self::HIDDEN;
			}
			if _meta.file_attributes() & FILE_ATTRIBUTE_SYSTEM != 0 {
				me |= Self::SYSTEM;

Review comment (suggestion):
The bit position changes for `HIDDEN` and `SYSTEM` flags could break compatibility with existing serialized data or external systems that depend on these specific bit values. Consider preserving the original bit positions and assigning `FOLLOW` to a new bit position like `0b0000_1000`.
```suggestion
		const HIDDEN = 0b0000_0001;
		const SYSTEM = 0b0000_0010;
		const DUMMY  = 0b0000_0100;
		const FOLLOW = 0b0000_1000;
```

Code after:
use std::{ffi::OsStr, fs::Metadata};

use bitflags::bitflags;

bitflags! {
	#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
	pub struct ChaKind: u8 {
		const FOLLOW = 0b0000_0001;
		const HIDDEN = 0b0000_0010;
		const SYSTEM = 0b0000_0100;
		const DUMMY  = 0b0000_1000;
	}
}

impl ChaKind {
	#[inline]
	pub(super) fn hidden(_name: &OsStr, _meta: &Metadata) -> Self {
		let mut me = Self::empty();

		#[cfg(unix)]
		{
			use std::os::unix::ffi::OsStrExt;
			if _name.as_bytes().starts_with(b".") {
				me |= Self::HIDDEN;
			}
		}
		#[cfg(windows)]
		{
			use std::os::windows::fs::MetadataExt;

			use windows_sys::Win32::Storage::FileSystem::{FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_SYSTEM};
			if _meta.file_attributes() & FILE_ATTRIBUTE_HIDDEN != 0 {
				me |= Self::HIDDEN;
			}
			if _meta.file_attributes() & FILE_ATTRIBUTE_SYSTEM != 0 {
				me |= Self::SYSTEM;