Add proper tar.gz support
This commit is contained in:
parent
9cc00b4e5b
commit
468ce8a178
3 changed files with 81 additions and 11 deletions
63
Cargo.lock
generated
63
Cargo.lock
generated
|
@ -295,9 +295,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.6"
|
||||
version = "3.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1957aa4a5fb388f0a0a73ce7556c5b42025b874e5cdc2c670775e346e97adec0"
|
||||
checksum = "12e8611f9ae4e068fa3e56931fded356ff745e70987ff76924a6e0ab1c8ef2e3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
|
@ -390,6 +390,18 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.1"
|
||||
|
@ -525,9 +537,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
|
@ -767,9 +779,9 @@ checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
|||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.2"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52"
|
||||
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
|
@ -1013,6 +1025,7 @@ dependencies = [
|
|||
"byte-unit",
|
||||
"bytes",
|
||||
"console_error_panic_hook",
|
||||
"flate2",
|
||||
"getrandom",
|
||||
"gloo-console",
|
||||
"http",
|
||||
|
@ -1020,6 +1033,7 @@ dependencies = [
|
|||
"omegaupload-common 0.1.0",
|
||||
"reqwasm",
|
||||
"serde",
|
||||
"tar",
|
||||
"tree_magic_mini",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
|
@ -1212,6 +1226,15 @@ dependencies = [
|
|||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
|
@ -1400,9 +1423,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.74"
|
||||
version = "1.0.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142"
|
||||
checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"
|
||||
dependencies = [
|
||||
"itoa 1.0.1",
|
||||
"ryu",
|
||||
|
@ -1488,9 +1511,9 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
|
|||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.7.0"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
|
||||
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
|
@ -1537,6 +1560,17 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8"
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
|
@ -2040,6 +2074,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xattr"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.4.3"
|
||||
|
|
|
@ -23,6 +23,8 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
wasm-bindgen = { version = "0.2", features = ["serde-serialize"]}
|
||||
wasm-bindgen-futures = "0.4"
|
||||
zip = { version = "0.5", default-features = false, features = ["deflate"] }
|
||||
flate2 = "1.0.22"
|
||||
tar = "0.4.38"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3"
|
||||
|
|
|
@ -111,7 +111,32 @@ pub fn decrypt(
|
|||
entries.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
DecryptedData::Archive(blob, entries)
|
||||
}
|
||||
ContentType::GzipArchive => DecryptedData::Archive(blob, vec![]),
|
||||
ContentType::GzipArchive => {
|
||||
let mut entries = vec![];
|
||||
let cursor = Cursor::new(container);
|
||||
let gzip_dec = flate2::read::GzDecoder::new(cursor);
|
||||
let mut archive = tar::Archive::new(gzip_dec);
|
||||
if let Ok(files) = archive.entries() {
|
||||
for file in files {
|
||||
if let Ok(file) = file {
|
||||
let file_path = if let Ok(file_path) = file.path() {
|
||||
file_path.display().to_string()
|
||||
} else {
|
||||
"<Invalid utf-8 path>".to_string()
|
||||
};
|
||||
entries.push(ArchiveMeta {
|
||||
name: file_path,
|
||||
file_size: file.size(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if entries.len() > 0 {
|
||||
DecryptedData::Archive(blob, entries)
|
||||
} else {
|
||||
DecryptedData::Blob(blob)
|
||||
}
|
||||
},
|
||||
ContentType::Unknown => DecryptedData::Blob(blob),
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue