Skip to content

DokanInstanceBuilder.Build returns before file system is ready #1210

@lostmsu

Description

@lostmsu

Trying to access the new file system immediately after it is built fails with ERROR_INVALID_FUNCTION or ERROR_INVALID_PARAMETER (depending on type of access).

IMHO, Build by default should wait for the file system to be ready.

Workaround

const uint ERROR_INVALID_PARAMETER = 0x0057;
bool done = false;
while(!done) {
    try {
        mountDir.EnumerateFileSystemInfos().Any();
        done = true;
    } catch (IOException e)
        when (GetWin32Error(e.HResult) == ERROR_INVALID_PARAMETER) {
        await Task.Delay(TimeSpan.FromMilliseconds(25), cancel)
                  .ConfigureAwait(false);
    }
}

static uint GetWin32Error(int hResult)
    => unchecked((uint)hResult) & 0xFFFF;

See also dokan-dev/dokan-dotnet#356

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions