@@ -36,7 +36,7 @@ use crate::config::OS::WINDOWS;
36
36
use crate :: {
37
37
format_one_arg, format_three_args, format_two_args, run_shell_command_by_os, Command , Logger ,
38
38
CP_VOLUME_COMMAND , HDIUTIL_ATTACH_COMMAND , HDIUTIL_DETACH_COMMAND , MACOS , MV_PAYLOAD_COMMAND ,
39
- MV_PAYLOAD_OLD_VERSIONS_COMMAND , MV_SFX_COMMAND , PKGUTIL_COMMAND ,
39
+ MV_PAYLOAD_OLD_VERSIONS_COMMAND , PKGUTIL_COMMAND ,
40
40
} ;
41
41
42
42
pub const PARSE_ERROR : & str = "Wrong browser/driver version" ;
@@ -135,7 +135,7 @@ pub fn uncompress(
135
135
} else if extension. eq_ignore_ascii_case ( DMG ) {
136
136
uncompress_dmg ( compressed_file, target, log, os, volume. unwrap_or_default ( ) ) ?
137
137
} else if extension. eq_ignore_ascii_case ( EXE ) {
138
- uncompress_sfx ( compressed_file, target, log, os ) ?
138
+ uncompress_sfx ( compressed_file, target, log) ?
139
139
} else if extension. eq_ignore_ascii_case ( XML ) || extension. eq_ignore_ascii_case ( HTML ) {
140
140
log. debug ( format ! (
141
141
"Wrong downloaded driver: {}" ,
@@ -156,26 +156,29 @@ pub fn uncompress_sfx(
156
156
compressed_file : & str ,
157
157
target : & Path ,
158
158
log : & Logger ,
159
- os : & str ,
160
159
) -> Result < ( ) , Box < dyn Error > > {
160
+ let zip_parent = Path :: new ( compressed_file) . parent ( ) . unwrap ( ) ;
161
161
log. trace ( format ! (
162
- "Uncompress {} to {}" ,
162
+ "Decompressing {} to {}" ,
163
163
compressed_file,
164
- target . display( )
164
+ zip_parent . display( )
165
165
) ) ;
166
+
166
167
let file_bytes = read_bytes_from_file ( compressed_file) ?;
167
168
let header = find_bytes ( & file_bytes, SEVEN_ZIP_HEADER ) ;
168
169
let index_7z = header. ok_or ( "Incorrect SFX (self extracting exe) file" ) ?;
169
170
let file_reader = Cursor :: new ( & file_bytes[ index_7z..] ) ;
170
- sevenz_rust:: decompress ( file_reader, target ) . unwrap ( ) ;
171
+ sevenz_rust:: decompress ( file_reader, zip_parent ) . unwrap ( ) ;
171
172
173
+ let zip_parent_str = path_buf_to_string ( zip_parent. to_path_buf ( ) ) ;
172
174
let target_str = path_buf_to_string ( target. to_path_buf ( ) ) ;
173
- let command = Command :: new_single ( format_two_args ( MV_SFX_COMMAND , & target_str, & target_str) ) ;
174
- log. trace ( format ! ( "Running command: {}" , command. display( ) ) ) ;
175
- run_shell_command_by_os ( os, command) ?;
176
-
177
- let setup_file = target. join ( "setup.exe" ) ;
178
- fs:: remove_file ( setup_file. as_path ( ) ) ?;
175
+ let core_str = format ! ( r#"{}\core"# , zip_parent_str) ;
176
+ log. trace ( format ! (
177
+ "Moving extracted files and folders from {} to {}" ,
178
+ core_str, target_str
179
+ ) ) ;
180
+ create_parent_path_if_not_exists ( target) ?;
181
+ fs:: rename ( & core_str, & target_str) ?;
179
182
180
183
Ok ( ( ) )
181
184
}
0 commit comments