NAME

Net::Blossom::Server::Backend::Filesystem::BlobStore - Blossom blob files

DESCRIPTION

This module implements Net::Blossom::Server::BlobStore using ordinary files. It is normally constructed by Net::Blossom::Server::Backend::Filesystem.

Files use generation-specific, hash-sharded paths below root/blobs. Uploads are staged below root/.staging, synchronized, and atomically hard-linked into place without overwriting an existing file.

CONSTRUCTOR

new

my $blobs = Net::Blossom::Server::Backend::Filesystem::BlobStore->new(
    root => '/srv/blossom',
);

Requires root. generation may provide a callback for generation filename suffixes; it defaults to random 128-bit hexadecimal values. A suffix must begin with an ASCII letter or digit and contain only ASCII letters, digits, periods, underscores, or hyphens. Reusing a suffix for the same hash makes prepare fail instead of overwriting the existing file.

The platform and filesystem must support hard links and directory synchronization. root/blobs and root/.staging must be on the same filesystem.

METHODS

BUILDARGS

Internal Class::Tiny constructor hook.

root

Returns the absolute filesystem root.

generation

Returns the callback used to create generation filename suffixes.

deploy_schema

Creates the root, blob, and staging directories. Repeated calls are safe.

begin_upload

Returns a file-backed upload writer.

get_blob

Returns '' for an empty file, a stream for a nonempty file, or undef when the file is absent. When size is supplied, a size mismatch is an error.

delete_blob

Deletes one file and reports whether it existed.