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

Remove aiofiles dependency #135

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Remove aiofiles dependency #135

merged 1 commit into from
Sep 17, 2024

Conversation

b-rowan
Copy link
Contributor

@b-rowan b-rowan commented Sep 13, 2024

Remove dependency on aiofiles, NamedTemporaryFile was causing issues. Replace temporary files with a temporary file in artifacts/tmp.

goosebit/api/v1/software/routes.py Outdated Show resolved Hide resolved
goosebit/updates/swdesc.py Outdated Show resolved Hide resolved
goosebit/updates/__init__.py Outdated Show resolved Hide resolved
@easybe
Copy link
Collaborator

easybe commented Sep 13, 2024

Remove dependency on aiofiles, NamedTemporaryFile was causing issues. Replace temporary files with a temporary file in artifacts/tmp.

What kind of issues?

@b-rowan
Copy link
Contributor Author

b-rowan commented Sep 13, 2024

Remove dependency on aiofiles, NamedTemporaryFile was causing issues. Replace temporary files with a temporary file in artifacts/tmp.

What kind of issues?

Was running into permissions errors. It wasn't entirely aiofiles, but the way we were opening and closing files. We opened the temp file at the top level, then tried to open it again in a function called inside that with block, and that was causing issues.

In this case though, I don't really see any reason to use aiofiles or temp files here, there doesn't seem like much benefit...

Remove dependency on aiofiles, `NamedTemporaryFile` was causing issues.
Replace temporary files with a temporary file in `artifacts/tmp`.
@b-rowan b-rowan linked an issue Sep 13, 2024 that may be closed by this pull request
@b-rowan b-rowan requested a review from tsagadar September 16, 2024 15:55
@tsagadar
Copy link
Collaborator

LGTM. Great to have that dependency removed!

@b-rowan b-rowan merged commit 18abbb3 into master Sep 17, 2024
5 checks passed
await f.write(await file.read())
absolute = await file_path.absolute()
software = await create_software_update(absolute.as_uri(), Path(f.name))
tmp_file_path = artifacts_dir.joinpath("tmp", ("".join(random.choices(string.ascii_lowercase, k=12)) + ".tmp"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change makes the artifact directory mandatory. Before, it was optional (when only using external artifacts) as temporary files were created in /tmp 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't even think about this. Maybe I can generate a temporary file location other than this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO it is best to use a standard temp location. But, we should make sure it works on all OSes.

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.

File moves may fail with OSError
3 participants