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 os.Copy over os.Rename to avoid os restrictions #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

emcfarlane
Copy link
Contributor

@emcfarlane emcfarlane commented Apr 23, 2024

In some environments the temp directory used for downloads may not be able to use os.Rename. In docker with caching enabled this fails, as the directory is a volume mount, with the error: "invalid cross-device link".

Another small fix is to hash the file using the io.Copy to avoid reading the binary into memory.

Another potential fix would be to use a temp file in the same directory as the destination file, maybe with the suffix .download. Then os.Rename could still be used, and failed downloads would still avoid populating the file.

In some environments the temp directory used for downloads may not be
able to use os.Rename. In docker with caching enabled this fails, as the
directory is a volume mount, with the error: "invalid cross-device
link".

Another small fix is to hash the file using the io.Copy to avoid reading
the binary into memory.
@emcfarlane emcfarlane changed the title Use copy over os.Rename to avoid os restrictions Use os.Copy over os.Rename to avoid os restrictions Apr 23, 2024
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

Successfully merging this pull request may close these issues.

1 participant