mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
cli: determine archive type based on filename instead of path (#224602)
Refs #219632 Seems like PRSS sometimes(?) doesn't return the full archive name in the response. I don't reproduce this, but others consistently do. This PR removes the dependency on the URL path and instead checks for the gzip magic number in the first two bytes of the archive to figure out what to do.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
use std::{ffi::OsStr, fmt, path::Path};
|
||||
use std::{fmt, path::Path};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -11,10 +11,11 @@ use crate::{
|
||||
constants::VSCODE_CLI_UPDATE_ENDPOINT,
|
||||
debug, log, options, spanf,
|
||||
util::{
|
||||
errors::{AnyError, CodeError, WrappedError},
|
||||
errors::{wrap, AnyError, CodeError, WrappedError},
|
||||
http::{BoxedHttp, SimpleResponse},
|
||||
io::ReportCopyProgress,
|
||||
tar, zipper,
|
||||
tar::{self, has_gzip_header},
|
||||
zipper,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -178,10 +179,10 @@ pub fn unzip_downloaded_release<T>(
|
||||
where
|
||||
T: ReportCopyProgress,
|
||||
{
|
||||
if compressed_file.extension() == Some(OsStr::new("zip")) {
|
||||
zipper::unzip_file(compressed_file, target_dir, reporter)
|
||||
} else {
|
||||
tar::decompress_tarball(compressed_file, target_dir, reporter)
|
||||
match has_gzip_header(compressed_file) {
|
||||
Ok((f, true)) => tar::decompress_tarball(f, target_dir, reporter),
|
||||
Ok((f, false)) => zipper::unzip_file(f, target_dir, reporter),
|
||||
Err(e) => Err(wrap(e, "error checking for gzip header")),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user