From f66fa8bf19c8cacdcd3554f2f399e0f4f8e6027a Mon Sep 17 00:00:00 2001 From: Robur Date: Wed, 7 Jul 2021 10:46:53 +0000 Subject: [PATCH] fixup 2021-07-07a: remove leftover orb.deb / orb.txz from build_artifacts --- bin/migrations/builder_migrations.ml | 6 ++++++ bin/migrations/m20210707a.ml | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 bin/migrations/m20210707a.ml diff --git a/bin/migrations/builder_migrations.ml b/bin/migrations/builder_migrations.ml index 3f8c90d..87dd954 100644 --- a/bin/migrations/builder_migrations.ml +++ b/bin/migrations/builder_migrations.ml @@ -90,6 +90,11 @@ let f20210308 = Cmdliner.Term.(const do_database_action $ const M20210308.fixup $ setup_log $ datadir), Cmdliner.Term.info ~doc "fixup-2021-03-08" +let f20210707a = + let doc = "Remove orb.deb and orb.txz that ended up in the build." in + Cmdliner.Term.(const do_database_action $ const M20210707a.fixup $ setup_log $ datadir), + Cmdliner.Term.info ~doc "fixup-2021-07-07a" + let help_cmd = let topic = let doc = "Migration to get help on" in @@ -124,5 +129,6 @@ let () = actions (module M20210630); actions (module M20210701); actions (module M20210706); + [ f20210707a ]; ]) |> Cmdliner.Term.exit diff --git a/bin/migrations/m20210707a.ml b/bin/migrations/m20210707a.ml new file mode 100644 index 0000000..13f94fc --- /dev/null +++ b/bin/migrations/m20210707a.ml @@ -0,0 +1,17 @@ +let orb_left_in_builds = + Caqti_request.collect ~oneshot:true + Caqti_type.unit + (Caqti_type.tup2 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath) + {| SELECT id, localpath FROM build_artifact + WHERE filepath = 'orb.deb' OR filepath = 'orb.txz' + |} + +let fixup datadir (module Db : Caqti_blocking.CONNECTION) = + let open Rresult.R.Infix in + Grej.check_version ~user_version:12L (module Db) >>= fun () -> + Db.rev_collect_list orb_left_in_builds () >>= fun leftover_orb -> + Grej.list_iter_result + (fun (id, path) -> + Bos.OS.File.delete (Fpath.append datadir path) >>= fun () -> + Db.exec Builder_db.Build_artifact.remove id) + leftover_orb