246V5TYIUL7CFN7G5Y7A35EEM6IJPN532ROEYVSM7Q4HCQSWPDBQC fn decode_file(&mut self, file: &str, buffer: &mut Vec<u8>) -> Result<(), Self::Error> {let mut uncoded = Vec::new();self.read_file(&file, &mut uncoded)?;let (mut decoded, encoding) = if tree_magic_mini::from_u8(&uncoded).starts_with("text/") {let mut detector = EncodingDetector::new();detector.feed(&uncoded, true);let encoding = detector.guess(None, true);debug!("guessed encoding = {:?}", encoding.name());let (decoded, encoding, malformed) = encoding.decode(&uncoded);debug!("final encoding = {:?}", encoding.name());if !malformed {(decoded.as_bytes().to_vec(), Some(encoding))} else {warn!("text file was malformed");(uncoded, None)}} else {(uncoded, None)};buffer.append(&mut decoded);Ok(())}
let mut uncoded = Vec::new();working_copy.read_file(&item.full_path, &mut uncoded)?;let encoding = if tree_magic_mini::from_u8(&uncoded).starts_with("text/") {let mut detector = EncodingDetector::new();detector.feed(&uncoded, true);let encoding = detector.guess(None, true);debug!("guessed encoding = {:?}", encoding.name());let (decoded, encoding, malformed) = encoding.decode(&uncoded);debug!("final encoding = {:?}", encoding.name());if !malformed {self.rec.contents.append(&mut decoded.as_bytes().to_vec());Some(encoding)} else {warn!("text file was malformed");self.rec.contents.append(&mut uncoded);None}} else {self.rec.contents.append(&mut uncoded);None};
working_copy.decode_file(&item.full_path, &mut self.rec.contents)?;