From 67af380185b7949c9c29db69238bbfd5a21591f8 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 17 Mar 2024 21:55:53 +0100 Subject: [PATCH] Hack: Displaying extractions in the status bar --- master_changes.md | 1 + src/repository/opamRepository.ml | 15 ++++++++++++++- tests/reftests/download.test | 8 ++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/master_changes.md b/master_changes.md index 956e5371781..cad62daaa71 100644 --- a/master_changes.md +++ b/master_changes.md @@ -56,6 +56,7 @@ users) ## Update / Upgrade * [BUG] Stop triggering "Undefined filter variable variable" warning for `?variable` [#5983 @dra27] + * Display extractions in the status bar [#5977 @dra27] ## Tree * [BUG] Fix `opam tree --with-*` assigning the `with-*` variables to unrequested packages [#5919 @kit-ty-kate @rjbou - fix #5755] diff --git a/src/repository/opamRepository.ml b/src/repository/opamRepository.ml index 39531ace163..826257a14bc 100644 --- a/src/repository/opamRepository.ml +++ b/src/repository/opamRepository.ml @@ -263,9 +263,11 @@ let pull_tree_t | Some e -> Done (Not_available (None, Printexc.to_string e)) in match dirnames with - | [ _label, local_dirname, _subpath ] -> + | [ label, local_dirname, _subpath ] -> (fun archive msg -> OpamFilename.cleandir local_dirname; + let text = OpamProcess.make_command_text label "extract" in + OpamProcess.Job.with_text text @@ OpamFilename.extract_job archive local_dirname @@+ fallback (fun () -> Done (Up_to_date msg))) | _ -> @@ -285,6 +287,17 @@ let pull_tree_t (Some label, OpamProcess.result_summary r)))) dirnames in + let text = + let label = + match dirnames with + | [(label1, _, _); (label2, _, _)] -> + label1 ^ ", " ^ label2 + | (label, _, _)::rest -> + Printf.sprintf "%s + %d others" label (List.length rest) + | [] -> assert false in + OpamProcess.make_command_text label "extract" + in + OpamProcess.Job.with_text text @@ OpamFilename.extract_job archive tmpdir @@+ fallback (fun () -> let failing = diff --git a/tests/reftests/download.test b/tests/reftests/download.test index fd7c9de4e21..23172f3ff03 100644 --- a/tests/reftests/download.test +++ b/tests/reftests/download.test @@ -19,7 +19,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] curl-or-wget -- "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" -Processing 1/1: +Processing 1/1: [foo.1: extract] + tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" Done. ### opam clean -c @@ -34,7 +34,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] + wget "--content-disposition" "-t" "3" "-O" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "-U" "opam/current" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" -Processing 1/1: +Processing 1/1: [foo.1: extract] + tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" Done. ### opam clean -c @@ -49,7 +49,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] + curl "--write-out" "%{http_code}\n" "--retry" "3" "--retry-delay" "2" "--user-agent" "opam/current" "-L" "-o" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" -Processing 1/1: +Processing 1/1: [foo.1: extract] + tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" Done. ### opam clean -c @@ -148,7 +148,7 @@ The following actions will be performed: <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> Processing 1/1: [foo.1: http] + wget "--content-disposition" "-t" "3" "-O" "${BASEDIR}/OPAM/download/.opam-switch/sources/foo.1/v1.0.0.tar.gz.part" "-U" "opam/current" "--" "https://github.com/UnixJunkie/get_line/archive/v1.0.0.tar.gz" -Processing 1/1: +Processing 1/1: [foo.1: extract] + tar "xfz" "${OPAMTMP}/v1.0.0.tar.gz" "-C" "${OPAMTMP}" Done. ### opam clean -c