@@ -251,6 +251,19 @@ let migrate_blobs ?did () =
251251 print_endline " migrating all blobs to S3" ;
252252 S3.Blob_migration. migrate_all ()
253253
254+ let rebuild_mst ~did () =
255+ print_endline (" rebuilding MST for " ^ did) ;
256+ let % lwt repo = Repository. load did in
257+ match % lwt Repository. rebuild_mst repo with
258+ | Ok (commit_cid , commit ) ->
259+ print_endline
260+ (Printf. sprintf " MST rebuilt successfully, new commit: %s (rev: %s)"
261+ (Cid. to_string commit_cid) commit.rev ) ;
262+ Lwt. return_unit
263+ | Error exn ->
264+ print_endline (" error rebuilding MST: " ^ Printexc. to_string exn ) ;
265+ exit 1
266+
254267let print_usage () =
255268 print_endline
256269 @@ String. trim
@@ -262,6 +275,7 @@ commands:
262275 create - invite [uses] create an invite code with an optional number of uses (default : 1 )
263276 migrate - blobs migrate all local blobs to S3
264277 migrate - blobs < did> migrate blobs for a specific user to S3
278+ rebuild - mst < did> rebuild MST from records table (recovery tool )
265279
266280see also : gen - keys
267281|}
@@ -280,6 +294,8 @@ let () =
280294 Lwt_main. run (migrate_blobs () )
281295 | [" migrate-blobs" ; did] ->
282296 Lwt_main. run (migrate_blobs ~did () )
297+ | [" rebuild-mst" ; did] ->
298+ Lwt_main. run (rebuild_mst ~did () )
283299 | [" help" ] | [" --help" ] | [" -h" ] ->
284300 print_usage ()
285301 | cmd :: _ ->
0 commit comments