Table of Contents

Class FileHashCache

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

The SHA-1 of a file, remembered for as long as the file has not changed.

public sealed class FileHashCache
Inheritance
FileHashCache
Inherited Members

Remarks

Identifying a mod on Modrinth means hashing its jar, and the Mods tab does that for every jar in the folder in two separate places: the update check, and working out which projects are already installed before pulling in a dependency. On a folder with a hundred mods that was two hundred full reads for one click, all of them producing the answers the other pass had just computed.

The key is the path plus the size plus the write time, which is what makes reuse safe: replace, update or re-download a jar and any of the three moves, so the cached answer is discarded rather than served for a file that is no longer the same one.

Methods

Clear()

Forgets everything. For a folder that changed in ways the stamps cannot see.

public void Clear()

Sha1Async(string, CancellationToken)

The file's SHA-1, hashing it only if this exact file has not been hashed already.

public Task<string> Sha1Async(string path, CancellationToken ct = default)

Parameters

path string
ct CancellationToken

Returns

Task<string>