File tree 5 files changed +14
-35
lines changed
5 files changed +14
-35
lines changed Original file line number Diff line number Diff line change @@ -195,19 +195,9 @@ let unpack ~target ~archive =
195
195
Pp.textf " unable to extract % S " (Path.to_string archive))
196
196
;;
197
197
198
- let with_download url checksum ~target ~ f =
198
+ let with_download url checksum ~f =
199
199
let url = OpamUrl.to_string url in
200
- let temp_dir =
201
- let prefix = " dune" in
202
- let suffix = Filename.basename url in
203
- match (target : Path.t) with
204
- | In_build_dir _ ->
205
- Temp.temp_in_dir Dir ~dir:(Lazy.force Temp_dir.in_build) ~prefix ~suffix
206
- | _ ->
207
- let parent = Path.parent_exn target in
208
- Path.mkdir_p parent;
209
- Temp.temp_in_dir Dir ~dir:parent ~prefix ~suffix
210
- in
200
+ let temp_dir = Temp.create Dir ~prefix:" dune" ~suffix:(Filename.basename url) in
211
201
let output = Path.relative temp_dir " download" in
212
202
Fiber.finalize ~finally:(fun () ->
213
203
Temp.destroy Dir temp_dir;
@@ -232,9 +222,10 @@ let with_download url checksum ~target ~f =
232
222
;;
233
223
234
224
let fetch_curl ~unpack:unpack_flag ~checksum ~target (url : OpamUrl.t) =
235
- with_download url checksum ~target ~ f:(fun output ->
225
+ with_download url checksum ~f:(fun output ->
236
226
match unpack_flag with
237
227
| false ->
228
+ Path.mkdir_p (Path.parent_exn target);
238
229
Path.rename output target;
239
230
Fiber.return @@ Ok ()
240
231
| true ->
Original file line number Diff line number Diff line change @@ -710,13 +710,7 @@ module At_rev = struct
710
710
let check_out { repo = { dir; _ } ; revision = Sha1 rev ; files = _ } ~target =
711
711
(* TODO iterate over submodules to output sources *)
712
712
let git = Lazy. force Vcs. git in
713
- let temp_dir =
714
- Temp. temp_in_dir
715
- Dir
716
- ~dir: (Lazy. force Temp_dir. in_build)
717
- ~prefix: " rev-store"
718
- ~suffix: rev
719
- in
713
+ let temp_dir = Temp. create Dir ~prefix: " rev-store" ~suffix: rev in
720
714
Fiber. finalize ~finally: (fun () ->
721
715
let + () = Fiber. return () in
722
716
Temp. destroy Dir temp_dir)
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ let bin =
11
11
12
12
let output_limit = 1_000_000
13
13
14
+ let temp_dir_in_build =
15
+ lazy
16
+ (let dir = Path. relative (Path. build Path.Build. root) " .temp" in
17
+ Path. mkdir_p dir;
18
+ dir)
19
+ ;;
20
+
14
21
let extract ~archive ~target =
15
22
let * () = Fiber. return () in
16
23
let tar = Lazy. force bin in
@@ -19,10 +26,8 @@ let extract ~archive ~target =
19
26
let suffix = Path. basename archive in
20
27
match target with
21
28
| In_build_dir _ ->
22
- Temp. temp_in_dir Dir ~dir: (Lazy. force Temp_dir. in_build) ~prefix ~suffix
23
- | _ ->
24
- let parent = Path. parent_exn target in
25
- Temp. temp_in_dir Dir ~dir: parent ~prefix ~suffix
29
+ Temp. temp_in_dir Dir ~dir: (Lazy. force temp_dir_in_build) ~prefix ~suffix
30
+ | _ -> Temp. create Dir ~prefix ~suffix
26
31
in
27
32
Fiber. finalize ~finally: (fun () ->
28
33
Temp. destroy Dir target_in_temp;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments