Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a separate Tempdir for arkade downloads #840

Open
mrichar1 opened this issue Jan 25, 2023 · 1 comment
Open

Use a separate Tempdir for arkade downloads #840

mrichar1 opened this issue Jan 25, 2023 · 1 comment

Comments

@mrichar1
Copy link
Contributor

I'm creating this issue as a precursor to the PR discussed in #501 as while I have started looking at the problem and having some ideas on how to fix it, 1) I am not a regular Go programmer, and 2) I need some guidance on how this should fit into arkade.

Instead of using what os.TempDir returns (i.e. /tmp or equivalent) arkade should create a unique tempdir for all writes - e.g the following (which creates unique dirs with the prefix 'arkade'):

ioutil.TempDir("", "arkade")

This directory needs to exist before any writes are made, and be cleaned up when arkade exits. I think the easiest approach is to make a utility function that when called creates this tempdir (if it hasn't already been done) and returns it's path. Then all the places that currently call os.TempDir can call this function instead. I'm guessing somewhere in pkg/download would be a good place for this to live?

Equally, there should be a 'cleanup' function called when arkade is finished. I'm not sure where this should be added, or where it should be called from?

Let me know if you think this approach is a viable one, and where the best places to insert this new code is, and I'll start drafting a PR.

@alexellis
Copy link
Owner

You should be able to use a pattern like arkade-** in the method mentioned above along with a defer os.RemoveDir where any error is ignored. Do you want to try it and put up a Pr? I'll give some guidance at that point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants