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

Overriding a file when using Builder #202

Open
brsnik opened this issue Nov 29, 2022 · 3 comments
Open

Overriding a file when using Builder #202

brsnik opened this issue Nov 29, 2022 · 3 comments

Comments

@brsnik
Copy link

brsnik commented Nov 29, 2022

Getting the following error:

Error: Custom { kind: AlreadyExists, error: PathError { path: "/tmp", err: Custom { kind: AlreadyExists, error: "too many temporary files exist" } } }

When creating a file using the Builder.

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let file = Builder::new().prefix("testsock").rand_bytes(0).tempfile()?;

    Ok(())
}

How can I override the file?

@Stebalien
Copy link
Owner

For now, you'd:

  1. Create the file.
  2. Call NamedTempFile::from_parts to create a wrapper that will auto-delete the file. Or just construct a TempPath from the path.

@kontsaki
Copy link

hello, what about making PathError public ?

@Stebalien
Copy link
Owner

Stebalien commented Sep 23, 2023 via email

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

No branches or pull requests

3 participants