mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 20:45:24 +00:00
Only compress regular file
This commit is contained in:
parent
8b7fae278b
commit
2ac464b186
@ -499,22 +499,30 @@ impl Cpio {
|
||||
}
|
||||
|
||||
impl CpioEntry {
|
||||
pub(crate) fn compress(&mut self) -> LoggedResult<()> {
|
||||
pub(crate) fn compress(&mut self) -> bool {
|
||||
if self.mode & S_IFMT != S_IFREG {
|
||||
return false;
|
||||
}
|
||||
let mut compressed = Vec::new();
|
||||
if !xz(&self.data, &mut compressed) {
|
||||
return Err(log_err!("xz compression failed"));
|
||||
eprintln!("xz compression failed");
|
||||
return false;
|
||||
}
|
||||
self.data = compressed;
|
||||
Ok(())
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn decompress(&mut self) -> LoggedResult<()> {
|
||||
pub(crate) fn decompress(&mut self) -> bool {
|
||||
if self.mode & S_IFMT != S_IFREG {
|
||||
return false;
|
||||
}
|
||||
let mut decompressed = Vec::new();
|
||||
if !unxz(&self.data, &mut decompressed) {
|
||||
return Err(log_err!("xz decompression failed"));
|
||||
eprintln!("xz decompression failed");
|
||||
return false;
|
||||
}
|
||||
self.data = decompressed;
|
||||
Ok(())
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl MagiskCpio for Cpio {
|
||||
rm_list.push_str(data);
|
||||
}
|
||||
} else if name != ".backup/.magisk" {
|
||||
let new_name = if name.ends_with(".xz") && entry.decompress().is_ok() {
|
||||
let new_name = if name.ends_with(".xz") && entry.decompress() {
|
||||
&name[8..name.len() - 3]
|
||||
} else {
|
||||
&name[8..]
|
||||
@ -175,7 +175,7 @@ impl MagiskCpio for Cpio {
|
||||
};
|
||||
match action {
|
||||
Action::Backup(name, mut entry) => {
|
||||
let backup = if !skip_compress && entry.compress().is_ok() {
|
||||
let backup = if !skip_compress && entry.compress() {
|
||||
format!(".backup/{}.xz", name)
|
||||
} else {
|
||||
format!(".backup/{}", name)
|
||||
|
Loading…
Reference in New Issue
Block a user