2022-04-04 16:30:21 +00:00
|
|
|
open Grej.Infix
|
2021-07-12 14:10:54 +00:00
|
|
|
|
|
|
|
let all_build_artifacts_like_hashes : (unit, [`build_artifact] Builder_db.Rep.id * Fpath.t, [ `Zero | `One | `Many ]) Caqti_request.t =
|
2022-04-04 16:30:21 +00:00
|
|
|
Caqti_type.unit ->*
|
2024-08-13 11:07:50 +00:00
|
|
|
Caqti_type.t2 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath @@
|
2022-04-04 16:30:21 +00:00
|
|
|
"SELECT id, localpath FROM build_artifact WHERE filepath LIKE '%.build-hashes'"
|
2021-07-12 14:10:54 +00:00
|
|
|
|
|
|
|
let all_build_artifacts_like_readme : (unit, [`build_artifact] Builder_db.Rep.id * Fpath.t, [ `Zero | `One | `Many ]) Caqti_request.t =
|
2022-04-04 16:30:21 +00:00
|
|
|
Caqti_type.unit ->*
|
2024-08-13 11:07:50 +00:00
|
|
|
Caqti_type.t2 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath @@
|
2022-04-04 16:30:21 +00:00
|
|
|
"SELECT id, localpath FROM build_artifact WHERE filepath LIKE '%README.md'"
|
2021-07-12 14:10:54 +00:00
|
|
|
|
|
|
|
let fixup datadir (module Db : Caqti_blocking.CONNECTION) =
|
|
|
|
Grej.check_version ~user_version:13L (module Db) >>= fun () ->
|
|
|
|
Db.rev_collect_list all_build_artifacts_like_hashes () >>= fun build_artifacts_build_hashes ->
|
|
|
|
Db.rev_collect_list all_build_artifacts_like_readme () >>= fun build_artifacts_readme ->
|
|
|
|
Grej.list_iter_result
|
|
|
|
(fun (artifact_id, artifact_lpath) ->
|
|
|
|
Bos.OS.File.delete (Fpath.append datadir artifact_lpath) >>= fun () ->
|
|
|
|
Db.exec Builder_db.Build_artifact.remove artifact_id)
|
|
|
|
(build_artifacts_build_hashes @ build_artifacts_readme)
|