feat: give indication to original filenames in bulk rename

This commit is contained in:
MikuGeek 2025-03-18 23:32:11 +08:00
parent e138364102
commit 1ca98cc875

View file

@ -26,12 +26,16 @@ impl Mgr {
tokio::spawn(async move {
let tmp = YAZI.preview.tmpfile("bulk");
let s = old.iter().map(|o| o.as_os_str()).collect::<Vec<_>>().join(OsStr::new("\n"));
const DIVIDER: &str = "\n<↑ After ↑> <↓ Before ↓>\n";
let content = [&s, OsStr::new(&format!("{}", DIVIDER)), &s].join(OsStr::new(""));
OpenOptions::new()
.write(true)
.create_new(true)
.open(&tmp)
.await?
.write_all(s.as_encoded_bytes())
.write_all(content.as_encoded_bytes())
.await?;
defer! { tokio::spawn(fs::remove_file(tmp.clone())); }
@ -45,7 +49,10 @@ impl Mgr {
defer!(AppProxy::resume());
AppProxy::stop().await;
let new: Vec<_> = fs::read_to_string(&tmp).await?.lines().map(PathBuf::from).collect();
let content = fs::read_to_string(&tmp).await?;
let new: Vec<_> =
content.split(DIVIDER).next().unwrap_or("").lines().map(PathBuf::from).collect();
Self::bulk_rename_do(root, old, new).await
});
}