Commit d64c168 1 parent ab78772 commit d64c168 Copy full SHA for d64c168
File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 1
1
use std:: fs:: { self , File } ;
2
- use std:: io:: { Cursor , SeekFrom , Write } ;
3
2
use std:: io:: prelude:: * ;
3
+ use std:: io:: SeekFrom ;
4
4
use std:: path:: { self , Path , PathBuf } ;
5
5
use std:: sync:: Arc ;
6
6
@@ -370,16 +370,14 @@ fn tar(
370
370
header. set_path ( & path) . chain_err ( || {
371
371
format ! ( "failed to add to archive: `{}`" , fnd)
372
372
} ) ?;
373
- let mut buff = Cursor :: new ( Vec :: with_capacity ( 256 ) ) ;
374
- writeln ! ( buff, "{}" , serde_json:: to_string_pretty( json) ?) ?;
373
+ let json = format ! ( "{}\n " , serde_json:: to_string_pretty( json) ?) ;
375
374
let mut header = Header :: new_ustar ( ) ;
376
375
header. set_path ( & path) ?;
377
376
header. set_entry_type ( EntryType :: file ( ) ) ;
378
377
header. set_mode ( 0o644 ) ;
379
- header. set_size ( buff . position ( ) as u64 ) ;
378
+ header. set_size ( json . len ( ) as u64 ) ;
380
379
header. set_cksum ( ) ;
381
- buff. seek ( SeekFrom :: Start ( 0 ) ) ?;
382
- ar. append ( & header, & mut buff) . chain_err ( || {
380
+ ar. append ( & header, json. as_bytes ( ) ) . chain_err ( || {
383
381
internal ( format ! ( "could not archive source file `{}`" , fnd) )
384
382
} ) ?;
385
383
}
You can’t perform that action at this time.
0 commit comments