@@ -3,6 +3,7 @@ use super::Tarballer;
3
3
use crate :: compression:: CompressionFormats ;
4
4
use crate :: util:: * ;
5
5
use anyhow:: { bail, format_err, Context , Result } ;
6
+ use std:: collections:: BTreeSet ;
6
7
use std:: io:: Write ;
7
8
use std:: path:: Path ;
8
9
@@ -121,13 +122,14 @@ impl Generator {
121
122
122
123
/// Copies the `src` directory recursively to `dst`, writing `manifest.in` too.
123
124
fn copy_and_manifest ( src : & Path , dst : & Path , bulk_dirs : & str ) -> Result < ( ) > {
124
- let manifest = create_new_file ( dst. join ( "manifest.in" ) ) ?;
125
+ let mut manifest = create_new_file ( dst. join ( "manifest.in" ) ) ?;
125
126
let bulk_dirs: Vec < _ > = bulk_dirs
126
127
. split ( ',' )
127
128
. filter ( |s| !s. is_empty ( ) )
128
129
. map ( Path :: new)
129
130
. collect ( ) ;
130
131
132
+ let mut paths = BTreeSet :: new ( ) ;
131
133
copy_with_callback ( src, dst, |path, file_type| {
132
134
// We need paths to be compatible with both Unix and Windows.
133
135
if path
@@ -157,14 +159,20 @@ fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
157
159
if file_type. is_dir ( ) {
158
160
// Only manifest directories that are explicitly bulk.
159
161
if bulk_dirs. contains ( & path) {
160
- writeln ! ( & manifest , "dir:{}" , string) ? ;
162
+ paths . insert ( format ! ( "dir:{}\n " , string) ) ;
161
163
}
162
164
} else {
163
165
// Only manifest files that aren't under bulk directories.
164
166
if !bulk_dirs. iter ( ) . any ( |d| path. starts_with ( d) ) {
165
- writeln ! ( & manifest , "file:{}" , string) ? ;
167
+ paths . insert ( format ! ( "file:{}\n " , string) ) ;
166
168
}
167
169
}
168
170
Ok ( ( ) )
169
- } )
171
+ } ) ?;
172
+
173
+ for path in paths {
174
+ manifest. write_all ( path. as_bytes ( ) ) ?;
175
+ }
176
+
177
+ Ok ( ( ) )
170
178
}
0 commit comments