preparing for v1.100.0

This commit is contained in:
Mick Grove 2026-05-18 16:11:15 -07:00
commit d125d68e88

View file

@ -10,7 +10,9 @@ pub fn is_compressed_file(path: &Path) -> bool {
};
// Check for compound extensions first
if filename.ends_with(".tar.gz")
|| filename.ends_with(".tar.gzip")
|| filename.ends_with(".tar.bz2")
|| filename.ends_with(".tar.bzip2")
|| filename.ends_with(".tar.xz")
{
return true;
@ -19,8 +21,10 @@ pub fn is_compressed_file(path: &Path) -> bool {
if let Some(ext) = path.extension().and_then(|s| s.to_str()) {
let ext_lower = ext.to_lowercase();
ext_lower == "gz"
|| ext_lower == "gzip"
|| ext_lower == "tgz"
|| ext_lower == "bz2"
|| ext_lower == "bzip2"
|| ext_lower == "xz"
|| ext_lower == "tar"
|| ext_lower == "zlib"
@ -63,3 +67,22 @@ pub fn is_sqlite_file(path: &Path) -> bool {
pub fn has_sqlite_magic(data: &[u8]) -> bool {
data.len() >= SQLITE_MAGIC.len() && data[..SQLITE_MAGIC.len()] == *SQLITE_MAGIC
}
#[cfg(test)]
mod tests {
use std::path::Path;
use super::is_compressed_file;
#[test]
fn recognizes_tar_wrapped_long_compression_extensions() {
assert!(is_compressed_file(Path::new("archive.tar.gzip")));
assert!(is_compressed_file(Path::new("archive.tar.bzip2")));
}
#[test]
fn recognizes_long_single_compression_extensions() {
assert!(is_compressed_file(Path::new("payload.gzip")));
assert!(is_compressed_file(Path::new("payload.bzip2")));
}
}