From c482355ce9654437da82cd79b29a997428716f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Mon, 3 Apr 2023 12:50:53 +0200 Subject: [PATCH] Fix EMLINK on Windows (again) (#7472) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Ojeda Bär --- CHANGES.md | 3 +++ otherlibs/stdune/src/io.ml | 4 +++- src/dune_cache/local.ml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 56a1f648175..75444af38dc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,9 @@ - Pass correct flags when compiling `stdlib.ml`. (#7241, @emillon) +- Handle "Too many links" errors when using Dune cache on Windows. The fix in + 3.7.0 for this same issue was not effective due to a typo. (#7472, @nojb) + 3.7.0.post1 (2023-02-21) ------------------------ diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml index 33846e94dd5..ba3d21f9e82 100644 --- a/otherlibs/stdune/src/io.ml +++ b/otherlibs/stdune/src/io.ml @@ -339,7 +339,9 @@ let portable_hardlink ~src ~dst = filter out the duplicates first. *) Path.unlink dst; Path.link src dst - | Unix.Unix_error (Unix.EMLINK, _, _) -> + | Unix.Unix_error (Unix.EMLINK, _, _) + | Unix.Unix_error (Unix.EUNKNOWNERR -1142, _, _) + (* Needed for OCaml < 5.1 *) -> (* If we can't make a new hard link because we reached the limit on the number of hard links per file, we fall back to copying. We expect that this happens very rarely (probably only for empty files). *) diff --git a/src/dune_cache/local.ml b/src/dune_cache/local.ml index 20a1de1f67b..e6518b0e37c 100644 --- a/src/dune_cache/local.ml +++ b/src/dune_cache/local.ml @@ -61,7 +61,7 @@ let link_even_if_there_are_too_many_links_already ~src ~dst = try Path.link src dst with | Unix.Unix_error (Unix.EMLINK, _, _) - | Unix.Unix_error (Unix.EUNKNOWNERR -1442, _, _) (* Needed for OCaml < 5.1 *) + | Unix.Unix_error (Unix.EUNKNOWNERR -1142, _, _) (* Needed for OCaml < 5.1 *) -> Temp.with_temp_file ~dir:temp_dir ~prefix:"dune" ~suffix:"copy" ~f:(function | Error e -> raise e