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3NIVOVJ6MUCZPRAWIEWOV6TWQC
X243Z3Y54ULINQMMRIKLHRV5T237B7VUOAHVJ7DMPOQ6A6GQXY2AC
UM5DLRPBCQZQBEDJDLDPKODOKLACUHZD6YL6S4JRNKW6JLPNUVSAC
Q3GU26WDEYE2HXMM4WWNEGVMSXLQAKRJBSB2EJZA6JTHPKQHXCXQC
BZCGXVS77ZS3N4QPLIHNWZ3YFVV7H4PXQD3U6RN5ZFVOC7QL7MBQC
EAZ45JTF44727P34UQAMIFQQTSXFKABIG4PLBGC7C7KQ74GUSDPAC
#[test]
fn delete_non_utf8_file_test() -> Result<(), anyhow::Error> {
env_logger::try_init().unwrap_or(());
let mut buf = Vec::new();
use std::io::Read;
let mut fh = std::fs::File::open("src/tests/data/gb.1")?;
fh.read_to_end(&mut buf)?;
let mut repo = working_copy::memory::Memory::new();
repo.add_file("file", buf);
let env = pristine::sanakirja::Pristine::new_anon()?;
let mut txn = env.mut_txn_begin();
let mut channel = txn.open_or_create_channel("main")?;
txn.add_file("file")?;
let store = changestore::memory::Memory::new();
record_all(&mut repo, &store, &mut txn, &mut channel, "")?;
let mut buf = Vec::new();
{
use std::io::Read;
let mut fh = std::fs::File::open("src/tests/data/8859-1.2")?;
fh.read_to_end(&mut buf)?;
}
repo.remove_path("file")?;
let (h1, change1) = record_all_change(&mut repo, &store, &mut txn, &mut channel, "")?;
let mut v = Vec::new();
change1
.write(
&store,
Some(h1),
|l, _p| format!("{}:{}", l.path, l.line),
true,
&mut v,
)
.unwrap();
let lines: Vec<&str> = std::str::from_utf8(&v)
.unwrap()
.lines()
.filter(|l| l.starts_with(|c| c == '-'))
.collect();
assert_eq!(
vec![
" -Chinese / 中文,普通话,汉语 (GB 2312 / GB-encoding)",
"- 你好"
],
lines
);
Ok(())
}
let name_start = ChangePosition(self.rec.contents.len().into());
let file_meta = FileMetadata {
metadata: meta,
basename: item.basename.as_str(),
};
file_meta.write(&mut self.rec.contents);
let name_end = ChangePosition(self.rec.contents.len().into());
self.rec.contents.push(0);
let name_start = ChangePosition(self.rec.contents.len().into());
let file_meta = FileMetadata {
metadata: meta,
basename: item.basename.as_str(),
encoding: encoding.clone(),
};
file_meta.write(&mut self.rec.contents);
let name_end = ChangePosition(self.rec.contents.len().into());
self.rec.contents.push(0);
let mut name = Vec::new();
let FileMetadata { basename, metadata } = changes
let mut meta = Vec::new();
let FileMetadata {
basename,
metadata,
encoding,
} = changes
if name.len() > 2 {
if let Ok(name) = std::str::from_utf8(&name[2..]) {
if !full_path.is_empty() {
full_path.push('/');
}
full_path.push_str(name);
}
let FileMetadata { basename: name, .. } = FileMetadata::read(&mut meta);
if !full_path.is_empty() {
full_path.push('/');