FileStore.Stat (file_store v0.2.1)

A struct that holds file information.

Fields

  • key - The unique identifier for the file.

  • etag - A fingerprint for the contents of a file. This is almost always an MD5 checksum.

  • size - The byte size of the file.

Link to this section Summary

Functions

Compute an MD5 checksum.

Compute the MD5 checksum of a file on disk.

Link to this section Types

Specs

t() :: %FileStore.Stat{etag: binary(), key: binary(), size: non_neg_integer()}

Link to this section Functions

Specs

checksum(binary() | Enum.t()) :: binary()

Compute an MD5 checksum.

Example

iex> FileStore.Stat.checksum("hello world")
"5eb63bbbe01eeed093cb22bb8f5acdc3"
Link to this function

checksum_file(path)

Specs

checksum_file(Path.t()) :: {:ok, binary()} | {:error, File.posix()}

Compute the MD5 checksum of a file on disk.

Example

iex> FileStore.Stat.checksum_file("test/fixtures/test.txt")
{:ok, "0d599f0ec05c3bda8c3b8a68c32a1b47"}

iex> FileStore.Stat.checksum_file("test/fixtures/missing.txt")
{:error, :enoent}