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

Make UploadableFile::get_data async for AsyncRead #82

Merged

Conversation

ColinKinloch
Copy link
Contributor

@ColinKinloch ColinKinloch commented Feb 14, 2025

I've been attempting to bump the version of this in obs-gitlab-runner from 0.5.0to 0.8.0.
It currently stores a map of path strings to tokio::Files for artifacts, but I've changed it to use a Vec<UploadableFile>.

My current implementation does this:

async fn get_data(&self) -> Result<Self::Data<'_>, ()> {
    let file = AsyncFile::open(&self.real_path).await.map_err(|_| {})?;
    Ok(Box::new(file.compat()))
}

I didn't make get_path async as it is used in a non async context and I'm not sure it's necessary.

@andrewshadura
Copy link

Nitpick: Preparing (not Prepairing)

@andrewshadura
Copy link

You return Result<_,_> but always Ok(_), I assume the reason is that you plan to support returning errors at some point in future?

Copy link

@andrewshadura andrewshadura left a comment

Choose a reason for hiding this comment

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

LGTM except a typo in the commit message.
I’d also expand the commit message to say more why Result is more appropriate.

dependabot bot and others added 3 commits March 13, 2025 12:53
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.68 to 0.10.70.
- [Release notes](https://github.com/sfackler/rust-openssl/releases)
- [Commits](sfackler/rust-openssl@openssl-v0.10.68...openssl-v0.10.70)

---
updated-dependencies:
- dependency-name: openssl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Preparing an AsyncRead outside of an async context is difficult and
should not be assumed to succeed for every implementation.
To fix clippy lifetime warnings on async trait
@ColinKinloch ColinKinloch force-pushed the async_uploadable_file_get_data branch from d7e8f10 to e0173d2 Compare March 13, 2025 12:56
@ColinKinloch
Copy link
Contributor Author

Maybe it would be a good idea to utilise async and Result in the demo-runner to make it look less speculative.

@emanueleaina emanueleaina merged commit 037549c into collabora:main Mar 14, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants