Skip to content

Use os.Copy over os.Rename to avoid os restrictions #7

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

emcfarlane
Copy link
Contributor

@emcfarlane emcfarlane commented Apr 23, 2024

This improves support for bufisk running in CI environments. Adds a fallback for os.Rename to call os.Copy. os.Rename can fail when the destination and source file are not in the same volume. This was noticed in a GitHub action workflow where downloads were mounted in a cache volume, the error "invalid cross-device link" was returned but we don't check for errors as they may be os specific.

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
@emcfarlane emcfarlane marked this pull request as draft March 19, 2025 18:47
@emcfarlane emcfarlane marked this pull request as ready for review March 19, 2025 19:09
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