@@ -94,36 +94,38 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
94
94
95
95
File :: create ( destination. item ( ) ) ?. write_all ( data. join ( "\n \n " ) . as_bytes ( ) ) ?;
96
96
97
- if !argument. index . is_empty ( ) {
98
- index. insert ( destination. path ) ; // request index file update
97
+ if !argument. index . is_none ( ) {
98
+ index. insert ( destination. path ) ; // request index file update in this location
99
99
}
100
100
}
101
101
102
102
// renew pending index files on items crawl completed
103
- for path in index {
104
- let subject = format ! ( "{path}{}" , argument. index) ;
103
+ if let Some ( ref index_argument) = argument. index {
104
+ for path in index {
105
+ let subject = format ! ( "{path}{index_argument}" ) ;
105
106
106
- let mut index = File :: create ( & subject) ?;
107
- let mut data = Vec :: with_capacity ( argument. limit ) ;
107
+ let mut index = File :: create ( & subject) ?;
108
+ let mut data = Vec :: with_capacity ( argument. limit ) ;
108
109
109
- let mut total = 0 ;
110
- for file in read_dir ( & path) ? {
111
- let name = file?. file_name ( ) . into_string ( ) . unwrap ( ) ;
110
+ let mut total = 0 ;
111
+ for file in read_dir ( & path) ? {
112
+ let name = file?. file_name ( ) . into_string ( ) . unwrap ( ) ;
112
113
113
- if name == argument . index {
114
- continue ;
115
- }
114
+ if & name == index_argument {
115
+ continue ;
116
+ }
116
117
117
- let mut buffer = String :: from ( "##" ) ; // correct heading levels
118
- File :: open ( format ! ( "{path}{name}" ) ) ?. read_to_string ( & mut buffer) ?;
119
- data. push ( buffer) ;
118
+ let mut buffer = String :: from ( "##" ) ; // correct heading levels
119
+ File :: open ( format ! ( "{path}{name}" ) ) ?. read_to_string ( & mut buffer) ?;
120
+ data. push ( buffer) ;
120
121
121
- total += 1 ;
122
- }
122
+ total += 1 ;
123
+ }
123
124
124
- index. write_all ( data. join ( "\n \n " ) . as_bytes ( ) ) ?;
125
+ index. write_all ( data. join ( "\n \n " ) . as_bytes ( ) ) ?;
125
126
126
- output. debug ( & format ! ( "renew `{subject}` (total: {total})" ) ) ;
127
+ output. debug ( & format ! ( "renew `{subject}` (total: {total})" ) ) ;
128
+ }
127
129
}
128
130
129
131
// print totals
0 commit comments