Skip to content

Commit

Permalink
fix: pass O_SHARE_DELETE when digesting files
Browse files Browse the repository at this point in the history
Fixes #8268

This flag corresponds to what `Stdlib.open_in` does. When passed, the
files can be removed while they are still open. This condition can
happen when background digests are enabled. This is a no-op everywhere
else.

This allows enabling background digests on Windows.

Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed Jul 25, 2023
1 parent 2bcf5e9 commit bccc862
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Unreleased
- Fix permission errors when `sendfile` is not available (#8234, fixes #8120,
@emillon)

- Disable background digests on Windows. This prevents an issue where
- Fix background file digests on Windows. This prevents an issue where
unremovable files would make dune crash when the shared cache is enabled.
(#8243, fixes #8228, @emillon)
(#8243, #8262, fixes #8228, fixes #8268, @emillon)

3.9.1 (2023-07-06)
------------------
Expand Down
5 changes: 1 addition & 4 deletions src/dune_config/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ let background_digests =
let t =
{ name = "background_digests"
; of_string = Toggle.of_string
; value =
(match Platform.OS.value with
| Linux -> `Enabled
| _ -> `Disabled)
; value = background_default
}
in
register t;
Expand Down
2 changes: 1 addition & 1 deletion src/dune_digest/dune_digest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
module Direct_impl : Digest_impl = struct
let file file =
let fd =
match Unix.openfile file [ Unix.O_RDONLY ] 0 with
match Unix.openfile file [ Unix.O_RDONLY; O_SHARE_DELETE ] 0 with
| fd -> fd
| exception Unix.Unix_error (Unix.EACCES, _, _) ->
raise (Sys_error (sprintf "%s: Permission denied" file))
Expand Down

0 comments on commit bccc862

Please sign in to comment.