@@ -152,7 +152,9 @@ impl OpStore for SimpleOpStore {
152
152
}
153
153
154
154
let path = self . views_dir ( ) . join ( id. hex ( ) ) ;
155
- let buf = fs:: read ( path) . map_err ( |err| io_to_read_error ( err, id) ) ?;
155
+ let buf = fs:: read ( & path)
156
+ . context ( & path)
157
+ . map_err ( |err| io_to_read_error ( err, id) ) ?;
156
158
157
159
let proto = crate :: protos:: op_store:: View :: decode ( & * buf)
158
160
. map_err ( |err| to_read_error ( err. into ( ) , id) ) ?;
@@ -161,18 +163,22 @@ impl OpStore for SimpleOpStore {
161
163
162
164
fn write_view ( & self , view : & View ) -> OpStoreResult < ViewId > {
163
165
let dir = self . views_dir ( ) ;
164
- let temp_file =
165
- NamedTempFile :: new_in ( & dir) . map_err ( |err| io_to_write_error ( err, "view" ) ) ?;
166
+ let temp_file = NamedTempFile :: new_in ( & dir)
167
+ . context ( & dir)
168
+ . map_err ( |err| io_to_write_error ( err, "view" ) ) ?;
166
169
167
170
let proto = view_to_proto ( view) ;
168
171
temp_file
169
172
. as_file ( )
170
173
. write_all ( & proto. encode_to_vec ( ) )
174
+ . context ( temp_file. path ( ) )
171
175
. map_err ( |err| io_to_write_error ( err, "view" ) ) ?;
172
176
173
177
let id = ViewId :: new ( blake2b_hash ( view) . to_vec ( ) ) ;
174
178
175
- persist_content_addressed_temp_file ( temp_file, dir. join ( id. hex ( ) ) )
179
+ let new_path = dir. join ( id. hex ( ) ) ;
180
+ persist_content_addressed_temp_file ( temp_file, & new_path)
181
+ . context ( & new_path)
176
182
. map_err ( |err| io_to_write_error ( err, "view" ) ) ?;
177
183
Ok ( id)
178
184
}
@@ -183,7 +189,9 @@ impl OpStore for SimpleOpStore {
183
189
}
184
190
185
191
let path = self . operations_dir ( ) . join ( id. hex ( ) ) ;
186
- let buf = fs:: read ( path) . map_err ( |err| io_to_read_error ( err, id) ) ?;
192
+ let buf = fs:: read ( & path)
193
+ . context ( & path)
194
+ . map_err ( |err| io_to_read_error ( err, id) ) ?;
187
195
188
196
let proto = crate :: protos:: op_store:: Operation :: decode ( & * buf)
189
197
. map_err ( |err| to_read_error ( err. into ( ) , id) ) ?;
@@ -200,18 +208,22 @@ impl OpStore for SimpleOpStore {
200
208
fn write_operation ( & self , operation : & Operation ) -> OpStoreResult < OperationId > {
201
209
assert ! ( !operation. parents. is_empty( ) ) ;
202
210
let dir = self . operations_dir ( ) ;
203
- let temp_file =
204
- NamedTempFile :: new_in ( & dir) . map_err ( |err| io_to_write_error ( err, "operation" ) ) ?;
211
+ let temp_file = NamedTempFile :: new_in ( & dir)
212
+ . context ( & dir)
213
+ . map_err ( |err| io_to_write_error ( err, "operation" ) ) ?;
205
214
206
215
let proto = operation_to_proto ( operation) ;
207
216
temp_file
208
217
. as_file ( )
209
218
. write_all ( & proto. encode_to_vec ( ) )
219
+ . context ( temp_file. path ( ) )
210
220
. map_err ( |err| io_to_write_error ( err, "operation" ) ) ?;
211
221
212
222
let id = OperationId :: new ( blake2b_hash ( operation) . to_vec ( ) ) ;
213
223
214
- persist_content_addressed_temp_file ( temp_file, dir. join ( id. hex ( ) ) )
224
+ let new_path = dir. join ( id. hex ( ) ) ;
225
+ persist_content_addressed_temp_file ( temp_file, & new_path)
226
+ . context ( & new_path)
215
227
. map_err ( |err| io_to_write_error ( err, "operation" ) ) ?;
216
228
Ok ( id)
217
229
}
@@ -345,8 +357,8 @@ impl OpStore for SimpleOpStore {
345
357
}
346
358
}
347
359
348
- fn io_to_read_error ( err : std :: io :: Error , id : & impl ObjectId ) -> OpStoreError {
349
- if err. kind ( ) == ErrorKind :: NotFound {
360
+ fn io_to_read_error ( err : PathError , id : & impl ObjectId ) -> OpStoreError {
361
+ if err. error . kind ( ) == ErrorKind :: NotFound {
350
362
OpStoreError :: ObjectNotFound {
351
363
object_type : id. object_type ( ) ,
352
364
hash : id. hex ( ) ,
@@ -368,7 +380,7 @@ fn to_read_error(
368
380
}
369
381
}
370
382
371
- fn io_to_write_error ( err : std :: io :: Error , object_type : & ' static str ) -> OpStoreError {
383
+ fn io_to_write_error ( err : PathError , object_type : & ' static str ) -> OpStoreError {
372
384
OpStoreError :: WriteObject {
373
385
object_type,
374
386
source : Box :: new ( err) ,
0 commit comments