Skip to content

Conversation

@rjbou
Copy link
Collaborator

@rjbou rjbou commented Sep 17, 2025

No description provided.

val with_tmp_dir_job: (Dir.t -> 'a OpamProcess.job) -> 'a OpamProcess.job

(** Raw function to create a temporary directory. No automatic cleanup *)
(** Raw function to create a temporary directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mk_* functions are misleading, they do not create anything but merely return a unique name. I think we should change this first

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. Especially with https://github.com/ocaml/opam/pull/6659/files#diff-38a34666fa25190dcc42466d8decbd8c6d5bb62952d05b09f0d233c37b3bd4d7R320 we have a case where we don't want to clean the temporary file, we should have both functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, there is indeed no need to have the non cleaned temporary files for opamfile variable as we stay in opam.

Copy link
Collaborator Author

@rjbou rjbou Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mk_* functions are misleading, they do not create anything but merely return a unique name. I think we should change this first

I've opened #6704 for that

if exists filename then Some filename else None

let mk_tmp_file () =
of_string @@ OpamSystem.mk_temp_dir ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creating new files by ""creating a directory"" feels a bit wrong

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because it is non well named, as you pointed on your previous message.

Comment on lines +98 to +99
if Sys.file_exists d then
Unix.rmdir d;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is redundant with the try ... with Unix_error _ block

Suggested change
if Sys.file_exists d then
Unix.rmdir d;
Unix.rmdir d;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants