@@ -246,20 +246,8 @@ impl HashContext {
246246 }
247247
248248 /// Update the entry state in the database, and wait for completion.
249- pub async fn update ( & self , hash : Hash , state : EntryState < Bytes > ) -> io:: Result < ( ) > {
250- let ( tx, rx) = oneshot:: channel ( ) ;
251- self . db ( )
252- . send (
253- meta:: Update {
254- hash,
255- state,
256- tx : Some ( tx) ,
257- span : tracing:: Span :: current ( ) ,
258- }
259- . into ( ) ,
260- )
261- . await ?;
262- rx. await . map_err ( |_e| io:: Error :: other ( "" ) ) ??;
249+ pub async fn update_await ( & self , hash : Hash , state : EntryState < Bytes > ) -> io:: Result < ( ) > {
250+ self . db ( ) . update_await ( hash, state) . await ?;
263251 Ok ( ( ) )
264252 }
265253
@@ -269,40 +257,13 @@ impl HashContext {
269257 data_location : DataLocation :: Inline ( Bytes :: new ( ) ) ,
270258 outboard_location : OutboardLocation :: NotNeeded ,
271259 } ) ) ;
272- }
273- let ( tx, rx) = oneshot:: channel ( ) ;
274- self . db ( )
275- . send (
276- meta:: Get {
277- hash,
278- tx,
279- span : tracing:: Span :: current ( ) ,
280- }
281- . into ( ) ,
282- )
283- . await
284- . ok ( ) ;
285- let res = rx. await . map_err ( io:: Error :: other) ?;
286- Ok ( res. state ?)
260+ } ;
261+ self . db ( ) . get ( hash) . await
287262 }
288263
289264 /// Update the entry state in the database, and wait for completion.
290265 pub async fn set ( & self , hash : Hash , state : EntryState < Bytes > ) -> io:: Result < ( ) > {
291- let ( tx, rx) = oneshot:: channel ( ) ;
292- self . db ( )
293- . send (
294- meta:: Set {
295- hash,
296- state,
297- tx,
298- span : tracing:: Span :: current ( ) ,
299- }
300- . into ( ) ,
301- )
302- . await
303- . map_err ( io:: Error :: other) ?;
304- rx. await . map_err ( |_e| io:: Error :: other ( "" ) ) ??;
305- Ok ( ( ) )
266+ self . db ( ) . set ( hash, state) . await
306267 }
307268
308269 pub async fn get_maybe_create ( & self , hash : Hash , create : bool ) -> api:: Result < BaoFileHandle > {
@@ -892,7 +853,7 @@ async fn finish_import_impl(import_data: ImportEntry, ctx: HashContext) -> io::R
892853 data_location,
893854 outboard_location,
894855 } ;
895- ctx. update ( hash, state) . await ?;
856+ ctx. update_await ( hash, state) . await ?;
896857 Ok ( ( ) )
897858}
898859
0 commit comments