@@ -127,7 +127,14 @@ pub fn scripted_fixture_repo_read_only_with_args(
127
127
if !script_result_directory. is_dir ( ) {
128
128
std:: fs:: create_dir_all ( & script_result_directory) ?;
129
129
match extract_archive ( & archive_file_path, & script_result_directory, script_identity) {
130
- Ok ( _) => { }
130
+ Ok ( ( archive_id, platform) ) => {
131
+ eprintln ! (
132
+ "Extracted fixture from archive '{}' ({}, {:?})" ,
133
+ archive_file_path. display( ) ,
134
+ archive_id,
135
+ platform
136
+ )
137
+ }
131
138
Err ( err) => {
132
139
if err. kind ( ) != std:: io:: ErrorKind :: NotFound {
133
140
eprintln ! ( "{}" , err) ;
@@ -201,7 +208,10 @@ const META_GIT_VERSION: &str = "git-version";
201
208
fn populate_meta_dir ( destination_dir : & Path , script_identity : u32 ) -> std:: io:: Result < PathBuf > {
202
209
let meta_dir = destination_dir. join ( META_DIR_NAME ) ;
203
210
std:: fs:: create_dir_all ( & meta_dir) ?;
204
- std:: fs:: write ( meta_dir. join ( META_IDENTITY ) , format ! ( "{}" , script_identity) . as_bytes ( ) ) ?;
211
+ std:: fs:: write (
212
+ meta_dir. join ( META_IDENTITY ) ,
213
+ format ! ( "{}-{}" , script_identity, if cfg!( windows) { "windows" } else { "unix" } ) . as_bytes ( ) ,
214
+ ) ?;
205
215
std:: fs:: write (
206
216
meta_dir. join ( META_GIT_VERSION ) ,
207
217
& std:: process:: Command :: new ( "git" ) . arg ( "--version" ) . output ( ) ?. stdout ,
@@ -211,21 +221,29 @@ fn populate_meta_dir(destination_dir: &Path, script_identity: u32) -> std::io::R
211
221
212
222
/// `required_script_identity` is the identity of the script that generated the state that is contained in `archive`.
213
223
/// If this is not the case, the arvhive will be ignored.
214
- fn extract_archive ( archive : & Path , destination_dir : & Path , required_script_identity : u32 ) -> std:: io:: Result < ( ) > {
224
+ fn extract_archive (
225
+ archive : & Path ,
226
+ destination_dir : & Path ,
227
+ required_script_identity : u32 ,
228
+ ) -> std:: io:: Result < ( u32 , Option < String > ) > {
215
229
let mut archive_buf = Vec :: < u8 > :: new ( ) ;
216
230
let mut decoder = xz2:: bufread:: XzDecoder :: new ( std:: io:: BufReader :: new ( std:: fs:: File :: open ( archive) ?) ) ;
217
231
std:: io:: copy ( & mut decoder, & mut archive_buf) ?;
218
232
219
233
let mut entry_buf = Vec :: < u8 > :: new ( ) ;
220
- let archive_identity: u32 = tar:: Archive :: new ( std:: io:: Cursor :: new ( & mut & * archive_buf) )
234
+ let ( archive_identity, platform ) : ( u32 , _ ) = tar:: Archive :: new ( std:: io:: Cursor :: new ( & mut & * archive_buf) )
221
235
. entries_with_seek ( ) ?
222
236
. filter_map ( |e| e. ok ( ) )
223
237
. find_map ( |mut e : tar:: Entry < ' _ , _ > | {
224
238
let path = e. path ( ) . ok ( ) ?;
225
239
if path. parent ( ) ?. file_name ( ) ? == META_DIR_NAME && path. file_name ( ) ? == META_IDENTITY {
226
240
entry_buf. clear ( ) ;
227
241
e. read_to_end ( & mut entry_buf) . ok ( ) ?;
228
- entry_buf. to_str ( ) . ok ( ) ?. trim ( ) . parse ( ) . ok ( )
242
+ let mut tokens = entry_buf. to_str ( ) . ok ( ) ?. trim ( ) . splitn ( 2 , '-' ) ;
243
+ match ( tokens. next ( ) , tokens. next ( ) ) {
244
+ ( Some ( id) , platform) => Some ( ( id. parse ( ) . ok ( ) ?, platform. map ( ToOwned :: to_owned) ) ) ,
245
+ _ => None ,
246
+ }
229
247
} else {
230
248
None
231
249
}
@@ -248,7 +266,7 @@ fn extract_archive(archive: &Path, destination_dir: &Path, required_script_ident
248
266
}
249
267
entry. unpack_in ( & destination_dir) ?;
250
268
}
251
- Ok ( ( ) )
269
+ Ok ( ( archive_identity , platform ) )
252
270
}
253
271
254
272
pub fn to_bstr_err ( err : nom:: Err < VerboseError < & [ u8 ] > > ) -> VerboseError < & BStr > {
0 commit comments