Snapshot_utils.Make
module Header : sig ... end
val create :
writer ->
Header.t ->
cancellable:bool ->
display_progress:
[ `Bar
| `Periodic_event of total:int -> progress:int -> Ptime.span -> unit Lwt.t ] ->
files:(string * string) list ->
dest:string ->
unit ->
unit Lwt.t
create writer header ~cancellable ~display_progress ~files ~dest
creates a snapshot archive with the header header
with the contents of files
. Each element of files
is a pair whose first component is the path of the file to include and the second component is the "relative" path it should be registered to in the snapshot archive The archive is produced in file dest
.
Setting cancellable
to true
ensures the promise returned by create
can be canceled. How progress is advertized is controlled by the display_progress
variable. Note that `Bar
is not compatible with Lwt_exit
.
val extract :
reader_input ->
cancellable:bool ->
display_progress:[ `Bar | `Periodic_event of Ptime.span -> unit Lwt.t ] ->
dest:string ->
unit Lwt.t
extract reader_input ~cancellable ~display_progress ~dest
extracts the snapshot archive opened in reader_input
in the directory dest
. Existing files in dest
with the same names are overwritten.
Setting cancellable
to true
ensures the promise returned by extract
can be canceled. How progress is advertized is controlled by the display_progress
variable. Note that `Bar
is not compatible with Lwt_exit
.
val compress :
cancellable:bool ->
display_progress:
[ `Bar
| `Periodic_event of total:int -> progress:int -> Ptime.span -> unit Lwt.t ] ->
snapshot_file:string ->
unit ->
string Lwt.t
compress ~cancellable ~display_progress ~snapshot_file
compresses the snapshot archive snapshot_file
of the form "path/to/snapshot.uncompressed"
to a new file "path/to/snapshot"
whose path is returned. snapshot_file
is removed upon successful compression.
Setting cancellable
to true
ensures the promise returned by compress
can be canceled. How progress is advertized is controlled by the display_progress
variable. Note that `Bar
is not compatible with Lwt_exit
.
val with_open_snapshot :
progress:bool ->
string ->
(Header.t -> reader_input -> 'a Tezos_base.TzPervasives.tzresult Lwt.t) ->
'a Tezos_base.TzPervasives.tzresult Lwt.t
with_open_snapshot file f
opens the snapshot file for reading, reads its header and executes f
then finally closes the channels. file
can be a local file, a URL (in which case the snapshot is downloaded) or "-"
for reading from standard input.