@@ -50,6 +50,10 @@ struct Opt {
50
50
/// The size of the batches sent to Meilisearch.
51
51
#[ structopt( long, default_value = "20 MiB" ) ]
52
52
batch_size : Byte ,
53
+
54
+ /// The number of batches to skip. Useful when the upload stopped for some reason.
55
+ #[ structopt( long) ]
56
+ skip_batches : Option < u64 > ,
53
57
}
54
58
55
59
fn send_data (
@@ -122,19 +126,25 @@ fn main() -> anyhow::Result<()> {
122
126
123
127
match mime {
124
128
Mime :: Json => {
125
- let data = fs:: read_to_string ( file) ?;
126
- send_data ( & opt, & agent, & pb, & mime, data. as_bytes ( ) ) ?;
129
+ if opt. skip_batches . zip ( pb. length ( ) ) . map_or ( true , |( s, l) | s > l) {
130
+ let data = fs:: read_to_string ( file) ?;
131
+ send_data ( & opt, & agent, & pb, & mime, data. as_bytes ( ) ) ?;
132
+ }
127
133
pb. inc ( 1 ) ;
128
134
}
129
135
Mime :: NdJson => {
130
136
for chunk in nd_json:: NdJsonChunker :: new ( file, size) {
131
- send_data ( & opt, & agent, & pb, & mime, & chunk) ?;
137
+ if opt. skip_batches . zip ( pb. length ( ) ) . map_or ( true , |( s, l) | s > l) {
138
+ send_data ( & opt, & agent, & pb, & mime, & chunk) ?;
139
+ }
132
140
pb. inc ( 1 ) ;
133
141
}
134
142
}
135
143
Mime :: Csv => {
136
144
for chunk in csv:: CsvChunker :: new ( file, size) {
137
- send_data ( & opt, & agent, & pb, & mime, & chunk) ?;
145
+ if opt. skip_batches . zip ( pb. length ( ) ) . map_or ( true , |( s, l) | s > l) {
146
+ send_data ( & opt, & agent, & pb, & mime, & chunk) ?;
147
+ }
138
148
pb. inc ( 1 ) ;
139
149
}
140
150
}
0 commit comments