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

Add Filesystem::mount_or_else #57

Merged
merged 1 commit into from
May 22, 2024
Merged

Commits on May 22, 2024

  1. Add Filesystem::mount_or_else

    When mounting a filesystem, often code like this is used:
    
        if !Filesystem::is_mountable(alloc, storage) {
            Filesystem::format(storage).ok();
        }
        Filesystem::mount(alloc, storage)
    
    This mounts the filesystem twice because Filesystem::is_mountable is
    equivalent to Filesystem::mount(...).is_ok().  Depending on the storage
    implementation, mounting the filesystem can have significant cost.
    But directly calling Filesystem::mount and re-mounting in the error case
    is prohibited by the borrow checker.
    
    This patch adds a mount_or_else method that accepts a callable that is
    called on mount error.  Afterwards, mounting is re-tried.
    robin-nitrokey committed May 22, 2024
    Configuration menu
    Copy the full SHA
    2ad7785 View commit details
    Browse the repository at this point in the history