bbbfs

package
v0.1.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const HFScheme = "hf://"

HFScheme is the scheme prefix for Hugging Face paths.

Variables

View Source
var ErrWriteUnsupported = errors.New("bbbfs: write not supported")

ErrWriteUnsupported indicates that a backend does not support writes.

Functions

func AzAccountContainer added in v0.1.18

func AzAccountContainer(p string) (account, container string, err error)

AzAccountContainer returns the account and container from an Azure path. Returns empty strings for non-Azure paths.

func BaseName added in v0.1.18

func BaseName(p string) string

BaseName returns the base filename from any path.

func CanCopyServerSide added in v0.1.18

func CanCopyServerSide(src, dst string) bool

CanCopyServerSide returns true when both src and dst can use server-side copy.

func ChildPath added in v0.1.18

func ChildPath(parent, child string) string

ChildPath joins child to parent using the backend-specific separator.

func CopyServerSide added in v0.1.18

func CopyServerSide(ctx context.Context, src, dst string, concurrency int, sizeHint int64, onProgress CopyProgress) error

CopyServerSide performs an optimised server-side copy (e.g. Azure→Azure). sizeHint, when > 0, avoids a HeadBlob round-trip for the source size. Returns an error if the backends do not support server-side copy.

func Delete added in v0.1.18

func Delete(ctx context.Context, p string) error

Delete removes a file at the given path.

func DeletePrefix added in v0.1.18

func DeletePrefix(ctx context.Context, p string) error

DeletePrefix deletes all files under the prefix. Only Azure supports this natively.

func Exists added in v0.1.18

func Exists(ctx context.Context, p string) (bool, error)

Exists checks whether a file exists at the given path.

func ExistsAsBlob added in v0.1.18

func ExistsAsBlob(ctx context.Context, p string) (bool, error)

ExistsAsBlob checks whether the path points to an existing non-directory file. Returns false if the path is directory-like or does not exist.

func IsAz added in v0.1.18

func IsAz(path string) bool

IsAz returns true if the path targets an Azure Blob Storage backend.

func IsDirLike added in v0.1.18

func IsDirLike(ctx context.Context, p string) (bool, error)

IsDirLike checks whether the path is directory-like. For remote paths this is determined from the path structure; for local paths os.Stat is used.

func IsDirLikeFromPath added in v0.1.18

func IsDirLikeFromPath(p string) bool

IsDirLikeFromPath checks if a path is directory-like without making any network calls. Uses path structure only.

func IsHF added in v0.1.18

func IsHF(path string) bool

IsHF returns true if the path targets a Hugging Face backend.

func IsNonRetryableHTTPErr added in v0.1.18

func IsNonRetryableHTTPErr(err error) bool

IsNonRetryableHTTPErr returns true when err is an HTTP 401, 403, or 404 from any supported backend, indicating a non-retryable failure.

func IsRemote added in v0.1.18

func IsRemote(path string) bool

IsRemote returns true if the path targets a remote (non-local) backend.

func ListFilesFlat added in v0.1.18

func ListFilesFlat(ctx context.Context, p string) ([]string, error)

ListFilesFlat returns a flat list of relative file names under the path.

func ListRecursive

func ListRecursive(ctx context.Context, root string) <-chan ListResult

ListRecursive returns a channel that streams all files under the path. Entries are emitted as they are discovered; any listing error is sent as a ListResult with Err set. The channel is closed when listing completes or the context is cancelled. Callers should cancel the context if they stop consuming the channel early.

func ListRecursiveWithSizeStream added in v0.1.18

func ListRecursiveWithSizeStream(ctx context.Context, p string, emit func(Entry) error) error

ListRecursiveWithSizeStream streams all entries recursively with their sizes via a callback. If the backend does not implement streaming, it falls back to collecting all entries and emitting them one by one.

func ListStream added in v0.1.18

func ListStream(ctx context.Context, p string, fn func(Entry) error) error

ListStream lists entries via a streaming callback. Falls back to List when the backend does not provide a streaming implementation.

func MkDir added in v0.1.18

func MkDir(ctx context.Context, p string) error

MkDir creates a directory or container at the given path.

func ParseShareInfo added in v0.1.18

func ParseShareInfo(p string) (portal, direct string, err error)

ParseShareInfo returns shareable links for the path.

func PreAuthenticateAz added in v0.1.19

func PreAuthenticateAz(ctx context.Context, paths ...string) error

PreAuthenticateAz eagerly authenticates to the storage accounts referenced by the given az:// paths. Call this before spawning parallel workers so that any interactive login popups happen sequentially.

func Register

func Register(provider FS)

Register adds a filesystem provider.

func RegisterAzAccountRoles added in v0.1.19

func RegisterAzAccountRoles(srcPaths, dstPaths []string)

RegisterAzAccountRoles tags source and destination storage accounts with their roles so that SRC_AZURE_* / DST_AZURE_* environment variables are used for authentication in multi-tenant environments.

If the same account appears in both srcPaths and dstPaths it is not tagged with any role, so the normal (non-role-scoped) credential flow is used.

func ResolveDstPath added in v0.1.18

func ResolveDstPath(dst, base string, mustBeDir bool) (string, error)

ResolveDstPath computes the final destination file path for a copy operation. If the destination is directory-like, base is appended.

func ScanConcurrency added in v0.1.18

func ScanConcurrency(ctx context.Context) int

ScanConcurrency returns the scan concurrency stored in ctx, or 1 if unset.

func Touch added in v0.1.18

func Touch(ctx context.Context, p string) error

Touch creates an empty file or updates the modification time.

func UploadConcurrency added in v0.1.19

func UploadConcurrency(ctx context.Context) int

UploadConcurrency returns the upload concurrency stored in ctx, or 1 if unset.

func WithScanConcurrency added in v0.1.18

func WithScanConcurrency(ctx context.Context, n int) context.Context

WithScanConcurrency returns a context that carries the scan (listing) concurrency hint. Backends that support parallel prefix walking (e.g. Azure) use this to bound the number of concurrent listing goroutines.

func WithUploadConcurrency added in v0.1.19

func WithUploadConcurrency(ctx context.Context, n int) context.Context

WithUploadConcurrency returns a context that carries the upload concurrency hint for streaming uploads.

Types

type CopyProgress added in v0.1.18

type CopyProgress = func(copied, total int64)

CopyProgress is the callback type for copy progress reporting.

type Entry

type Entry struct {
	Name    string
	Path    string
	Size    int64
	IsDir   bool
	ModTime time.Time
}

Entry is a filesystem entry metadata.

func ListRecursiveWithSize added in v0.1.18

func ListRecursiveWithSize(ctx context.Context, p string) ([]Entry, error)

ListRecursiveWithSize lists all entries recursively with their sizes.

type FS

type FS interface {
	Match(path string) bool
	Read(ctx context.Context, path string) (io.ReadCloser, error)
	Write(ctx context.Context, path string, r io.Reader) error
	List(ctx context.Context, path string) ([]Entry, error)
	Stat(ctx context.Context, path string) (Entry, error)
}

FS provides abstract access for supported backends.

func Resolve

func Resolve(path string) FS

Resolve returns the first filesystem provider that matches the path.

type ListResult

type ListResult struct {
	Entry Entry
	Err   error
}

ListResult wraps an Entry with an optional error from a listing operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL