2021-03-08 16:01:00 +00:00
|
|
|
module Rep = Builder_db.Rep
|
|
|
|
|
2022-04-04 16:30:21 +00:00
|
|
|
open Grej.Infix
|
|
|
|
|
2021-03-08 16:01:00 +00:00
|
|
|
let broken_builds =
|
2024-08-13 11:07:50 +00:00
|
|
|
Caqti_type.unit ->* Caqti_type.t3 (Rep.id `build) Rep.uuid Caqti_type.string @@
|
2022-04-04 16:30:21 +00:00
|
|
|
{| SELECT b.id, b.uuid, job.name FROM build b, job
|
|
|
|
WHERE result_kind = 0 AND result_code = 0 AND main_binary IS NOT NULL AND job.id = b.job AND
|
|
|
|
(SELECT COUNT( * ) FROM build_artifact a
|
|
|
|
WHERE a.build = b.id and a.filepath = b.main_binary) = 0
|
|
|
|
|}
|
2021-03-08 16:01:00 +00:00
|
|
|
|
2021-11-12 13:01:40 +00:00
|
|
|
let fixup datadir (module Db : Caqti_blocking.CONNECTION) =
|
2021-03-10 09:50:15 +00:00
|
|
|
Grej.check_version ~user_version:3L (module Db) >>= fun () ->
|
2021-03-08 16:01:00 +00:00
|
|
|
Db.rev_collect_list broken_builds () >>= fun broken_builds ->
|
2021-03-12 08:47:28 +00:00
|
|
|
Grej.list_iter_result
|
2021-07-05 12:45:08 +00:00
|
|
|
(fun ((build, uuid, job_name) : [`build] Rep.id * Uuidm.t * string) ->
|
2021-11-12 13:01:40 +00:00
|
|
|
Format.printf "Removing job %a.\nPlease clean up data files in %a/%s/%a\n"
|
|
|
|
Uuidm.pp uuid Fpath.pp datadir job_name Uuidm.pp uuid;
|
2021-03-08 16:01:00 +00:00
|
|
|
Db.exec Builder_db.Build.remove build)
|
|
|
|
broken_builds
|