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

File moves may fail with OSError #130

Closed
b-rowan opened this issue Sep 9, 2024 · 4 comments · Fixed by #135
Closed

File moves may fail with OSError #130

b-rowan opened this issue Sep 9, 2024 · 4 comments · Fixed by #135
Assignees

Comments

@b-rowan
Copy link
Contributor

b-rowan commented Sep 9, 2024

await temp_file.rename(path)

May fail with OSError: [Errno 18] Invalid cross-device link: '/tmp/tmp0egb8ja1' -> 'goosebit/artifacts if target is on a different filesystem.

@jameshilliard
Copy link
Contributor

hmm, thinking we maybe need to put the tempfile in the artifacts directory somehow?

@b-rowan
Copy link
Contributor Author

b-rowan commented Sep 11, 2024

Fixed in #132 by using this instead, might as well have a separate PR -

        # basically os.rename, but sync and async versions of that break across filesystems
        async with await open_file(temp_file, "rb") as temp_file:
            async with await open_file(path, "wb") as file:
                while True:
                    chunk = await temp_file.read(1024 * 1024)
                    if not chunk:
                        break
                    await file.write(chunk)

@jameshilliard
Copy link
Contributor

Fixed in #132 by using this instead, might as well have a separate PR -

Maybe, should have this just as a fallback on failure of the rename?

@b-rowan
Copy link
Contributor Author

b-rowan commented Sep 11, 2024

Fixed in #132 by using this instead, might as well have a separate PR -

Maybe, should have this just as a fallback on failure of the rename?

Works for me, just catch OSError

@b-rowan b-rowan linked a pull request Sep 13, 2024 that will close this issue
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 a pull request may close this issue.

2 participants