mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-16 06:31:24 +01:00
Filter missing watches before hashing
This commit is contained in:
parent
efa64a4734
commit
8627db86be
4 changed files with 14 additions and 8 deletions
|
|
@ -6,9 +6,9 @@ let main = () => {
|
|||
| Ok((layout_directory, flake_specifier, other_args)) =>
|
||||
switch (preflight(layout_directory)) {
|
||||
| Ok () =>
|
||||
switch (Lib.Watches.get()) {
|
||||
switch (Lib.Watches.get_extant()) {
|
||||
| Ok(watches) =>
|
||||
let paths = Array.map(watch => watch.path, watches);
|
||||
let paths = List.map(watch => watch.path, watches);
|
||||
let hash =
|
||||
switch (Util.hash_files(paths)) {
|
||||
| Ok(hsh) => hsh
|
||||
|
|
@ -24,8 +24,8 @@ let main = () => {
|
|||
| (true, true) =>
|
||||
let profile_rc_mtime = Unix.stat(profile_rc).st_mtime;
|
||||
let all_older =
|
||||
Array.map(watch => watch.modtime, watches)
|
||||
|> Array.for_all(watch_mtime =>
|
||||
List.map(watch => watch.modtime, watches)
|
||||
|> List.for_all(watch_mtime =>
|
||||
watch_mtime <= int_of_float(profile_rc_mtime)
|
||||
);
|
||||
if (all_older) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ let hash_files = filenames => {
|
|||
let ctx = Sha1.init();
|
||||
let files_to_hash =
|
||||
filenames
|
||||
|> Array.to_list
|
||||
|> List.filter(f =>
|
||||
Sys.file_exists(f)
|
||||
? true
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ let get = () => {
|
|||
};
|
||||
};
|
||||
|
||||
let get_extant = () => {
|
||||
get()
|
||||
|> Result.map(watches =>
|
||||
watches |> Array.to_list |> List.filter(a => a.exists)
|
||||
);
|
||||
};
|
||||
|
||||
let get_path = doc => {
|
||||
let pth = doc |> member("path") |> to_string;
|
||||
String.sub(pth, 11, String.length(pth) - 11);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ let test_hash_one = () => {
|
|||
check_result_string(
|
||||
"Hash matches",
|
||||
Ok("6ead949bf4bcae230b9ed9cd11e578e34ce9f9ea"),
|
||||
hash_files([|"spit_version.sh"|]),
|
||||
hash_files(["spit_version.sh"]),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ let test_hash_multiple = () => {
|
|||
check_result_string(
|
||||
"Hash matches",
|
||||
Ok("f109b7892a541ed1e3cf39314cd25d21042b984f"),
|
||||
hash_files([|"spit_version.sh", "spit_version.sh"|]),
|
||||
hash_files(["spit_version.sh", "spit_version.sh"]),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ let test_hash_filters_nonexistent = () => {
|
|||
check_result_string(
|
||||
"Hash matches",
|
||||
Ok("6ead949bf4bcae230b9ed9cd11e578e34ce9f9ea"),
|
||||
hash_files([|"spit_version.sh", "FOOBARBAZ"|]),
|
||||
hash_files(["spit_version.sh", "FOOBARBAZ"]),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue