Use int instead of int64 for file sizes

We are not going to use the extra bit, and String.length returns the
size as an int anyway.
This commit is contained in:
Reynir Björnsson 2021-02-25 15:27:45 +01:00
parent 3046994f4c
commit 71cc34bac3
5 changed files with 8 additions and 8 deletions

View file

@ -12,7 +12,7 @@ type file = Rep.file = {
filepath : Fpath.t;
localpath : Fpath.t;
sha256 : Cstruct.t;
size : int64;
size : int;
}
let last_insert_rowid =

View file

@ -4,7 +4,7 @@ type file = {
filepath : Fpath.t;
localpath : Fpath.t;
sha256 : Cstruct.t;
size : int64;
size : int;
}
val application_id : int32

View file

@ -27,7 +27,7 @@ type file = {
filepath : Fpath.t;
localpath : Fpath.t;
sha256 : Cstruct.t;
size : int64;
size : int;
}
let uuid =
@ -62,10 +62,10 @@ let file =
Ok (filepath, localpath, sha256, size) in
let decode (filepath, localpath, sha256, size) =
Ok { filepath; localpath; sha256; size } in
Caqti_type.custom ~encode ~decode Caqti_type.(tup4 fpath fpath cstruct int64)
Caqti_type.custom ~encode ~decode Caqti_type.(tup4 fpath fpath cstruct int)
let file_opt =
let rep = Caqti_type.(tup4 (option fpath) (option fpath) (option cstruct) (option int64)) in
let rep = Caqti_type.(tup4 (option fpath) (option fpath) (option cstruct) (option int)) in
let encode = function
| Some { filepath; localpath; sha256; size } ->
Ok (Some filepath, Some localpath, Some sha256, Some size)

View file

@ -92,7 +92,7 @@ let save_exec build_dir exec =
save Fpath.(build_dir / "full") (Cstruct.to_string cs)
let save_file dir (filepath, data) =
let size = String.length data |> Int64.of_int in
let size = String.length data in
let sha256 = Mirage_crypto.Hash.SHA256.digest (Cstruct.of_string data) in
let localpath = Fpath.append dir filepath in
Lwt_result.lift (Bos.OS.Dir.create (Fpath.parent localpath)) >>= fun _ ->

View file

@ -86,7 +86,7 @@ let artifact ?(basename=false) job_name build { Builder_db.filepath; localpath =
[if basename
then txt (Fpath.basename filepath)
else txtf "%a" Fpath.pp filepath];
txtf " (%a) " Fmt.byte_size (Int64.to_int size);
txtf " (%a) " Fmt.byte_size size;
code [txtf "SHA256:%a" Hex.pp (Hex.of_cstruct sha256)];
]
@ -184,7 +184,7 @@ let job_build
[code [txtf "%a" Fpath.pp filepath]]];
dd [
code [txt "SHA256:"; txt sha256_hex];
txtf " (%a)" Fmt.byte_size (Int64.to_int size);
txtf " (%a)" Fmt.byte_size size;
];
])
artifacts);