123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137(*
* Copyright (c) 2018-2021 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)open!Importtypeempty=|moduletypeSubcommand=sigtyperunvalrun:runvalterm_internal:(unit->unit)Cmdliner.Term.t(** A pre-packaged [Cmdliner] term for executing {!run}. *)valterm:unitCmdliner.Term.t*Cmdliner.Term.info(** [term] is {!term_internal} plus documentation and logs initialisation *)endmoduletypeS=sig(** Reads basic metrics from an existing store and prints them to stdout. *)moduleStat:sigincludeSubcommandwithtyperun:=root:string->unitLwt.t(** Internal implementation utilities exposed for use in other integrity
checks. *)typesize=Bytesofint[@@derivingirmin]typeversion=[`V1|`V2][@@derivingirmin]typeio={size:size;offset:int63;generation:int63;version:version;}[@@derivingirmin]typefiles={pack:iooption;branch:iooption;dict:iooption}[@@derivingirmin]typeobjects={nb_commits:int;nb_nodes:int;nb_contents:int}[@@derivingirmin]valv:root:string->version:Version.t->filesvaldetect_version:root:string->Version.tvaltraverse_index:root:string->int->objectsendmoduleReconstruct_index:Subcommandwithtyperun:=root:string->output:stringoption->?index_log_size:int->unit->unit(** Rebuilds an index for an existing pack file *)(** Checks the integrity of a store *)moduleIntegrity_check:sigincludeSubcommandwithtyperun:=root:string->auto_repair:bool->unitLwt.tvalhandle_result:?name:string->([<`Fixedofint|`No_error],[<`Cannot_fixofstring|`Corruptedofint])result->unitend(** Checks the integrity of inodes in a store *)moduleIntegrity_check_inodes:sigincludeSubcommandwithtyperun:=root:string->heads:stringlistoption->unitLwt.tendvalcli:?terms:(unitCmdliner.Term.t*Cmdliner.Term.info)list->unit->empty(** Run a [Cmdliner] binary containing tools for running offline checks.
[terms] defaults to the set of checks in this module. *)endmoduletypeVersioned_store=sigincludeIrmin.SincludeS.Swithtyperepo:=repoandtypecommit:=commitendmoduletypeMaker=functor(_:Version.S)->Versioned_storetypeintegrity_error=[`Wrong_hash|`Absent_value]moduletypeSigs=sigtypeintegrity_error=[`Wrong_hash|`Absent_value]typenonrecempty=emptyvalsetup_log:unitCmdliner.Term.tvalpath:stringCmdliner.Term.tmoduletypeSubcommand=SubcommandmoduletypeS=SmoduletypeVersioned_store=Versioned_storemoduletypeMaker=MakermoduleMake(_:Maker):SmoduleIndex(Index:Pack_index.S):sigvalintegrity_check:?ppf:Format.formatter->auto_repair:bool->check:(kind:[>`Commit|`Contents|`Node]->offset:int63->length:int->Index.key->(unit,[<`Absent_value|`Wrong_hash])result)->Index.t->([>`Fixedofint|`No_error],[>`Cannot_fixofstring|`Corruptedofint])resultendend