FulcrumFS FulcrumFS
FulcrumFS FulcrumFS
DocFX + Singulink = ♥

Search Results for

    Method IRepoFile.GetLengthAsync

    IRepoFile.GetLengthAsync(CancellationToken)

    Gets the size of the content of the file in bytes.

    Declaration
    ValueTask<long> IRepoFile.GetLengthAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A cancellation token that cancels the operation.

    Returns
    Type Description
    ValueTask<long>

    The size of the file in bytes, which is also the Length of a stream opened over it.

    Implements
    IRepoFile.GetLengthAsync(CancellationToken)
    Remarks

    The size is obtained on demand and cached by the instance once it is known. Stored files never change, so it stays the same for as long as the file exists, and later calls answer without I/O, even after the file has been deleted. An implementation that already knows the size, for example from an earlier open or from the metadata a remote fetch returned, answers the first call without I/O as well.

    Files returned by an add know their size. For every file in the result of AddAsync(Stream, string, bool, IFileProcessingPipelineSelector, CancellationToken), AddAsync(Stream, string, bool, IFileProcessingPipelineSelector, CancellationToken), AddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken), TryAddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken) and GetOrAddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken) (the variants it added; those that already existed may read their size on demand), this method completes synchronously and requires no storage access or network round trip. The add has just written the content, so the size is known where that happened (a remote implementation returns it in the add response), and an application that adds a file and then records its size does not pay a round trip for reading it back. For fetched files (GetAsync(FileId), GetGroupAsync(FileId) and GetVariantAsync(FileId, string)) the size is read on the first call.

    This is a method rather than a property because a property would make every implementation produce the size when it fetches the file. A fetch finds a file by its name alone, so on a shared repository server that would be a separate metadata read for every fetched file and every member of a group, whether or not anyone asks for the size; the method costs nothing until it is called.

    Exceptions
    Type Condition
    IOException

    The size is not known yet and the content is no longer available, for example because a cleanup pass physically removed the file after it was fetched.

    OperationCanceledException

    The operation was canceled.

    © Singulink. All rights reserved.