Documentation
¶
Index ¶
- Constants
- Variables
- func AzAccountContainer(p string) (account, container string, err error)
- func BaseName(p string) string
- func CanCopyServerSide(src, dst string) bool
- func CanCopyServerSideFromURL(src, dst string) bool
- func CanDownloadToFile(src string) bool
- func CanUploadFromFile(dst string) bool
- func ChildPath(parent, child string) string
- func CopyServerSide(ctx context.Context, src, dst string, concurrency int, sizeHint int64, ...) error
- func CopyServerSideFromURL(ctx context.Context, src, dst string, concurrency int, onProgress CopyProgress) error
- func Delete(ctx context.Context, p string) error
- func DeletePrefix(ctx context.Context, p string) error
- func DownloadToFile(ctx context.Context, src, localPath string, concurrency int, ...) (int64, error)
- func Exists(ctx context.Context, p string) (bool, error)
- func ExistsAsBlob(ctx context.Context, p string) (bool, error)
- func IsACR(path string) bool
- func IsAz(path string) bool
- func IsDirLike(ctx context.Context, p string) (bool, error)
- func IsDirLikeFromPath(p string) bool
- func IsGS(path string) bool
- func IsHF(path string) bool
- func IsNonRetryableHTTPErr(err error) bool
- func IsObjectStore(path string) bool
- func IsRemote(path string) bool
- func IsS3(path string) bool
- func ListFilesFlat(ctx context.Context, p string) ([]string, error)
- func ListRecursive(ctx context.Context, root string) <-chan ListResult
- func ListRecursiveWithSizeStream(ctx context.Context, p string, emit func(Entry) error) error
- func ListStream(ctx context.Context, p string, fn func(Entry) error) error
- func MkDir(ctx context.Context, p string) error
- func ParseShareInfo(p string) (portal, direct string, err error)
- func PreAuthenticateAz(ctx context.Context, paths ...string) error
- func Register(provider FS)
- func RegisterAzAccountRoles(srcPaths, dstPaths []string)
- func ResolveDstPath(dst, base string, mustBeDir bool) (string, error)
- func ScanConcurrency(ctx context.Context) int
- func Touch(ctx context.Context, p string) error
- func UploadArtifact(ctx context.Context, dst string, files []ArtifactFile, concurrency int, ...) error
- func UploadConcurrency(ctx context.Context) int
- func UploadFromFile(ctx context.Context, localPath, dst string, concurrency int, ...) (int64, error)
- func UploadReader(ctx context.Context, dst string, r io.Reader, concurrency int, ...) error
- func WithScanConcurrency(ctx context.Context, n int) context.Context
- func WithUploadConcurrency(ctx context.Context, n int) context.Context
- type ArtifactFile
- type CopyProgress
- type Entry
- type FS
- type ListResult
- type RecursiveSummary
Constants ¶
const ACRScheme = "acr://"
ACRScheme is the scheme prefix for Azure Container Registry paths.
const HFScheme = "hf://"
HFScheme is the scheme prefix for Hugging Face paths.
Variables ¶
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
AzAccountContainer returns the account and container from an Azure path. Returns empty strings for non-Azure paths.
func CanCopyServerSide ¶ added in v0.1.18
CanCopyServerSide returns true when both src and dst can use server-side copy. Server-side copy is only valid within the same provider (Azure→Azure or S3→S3, GCS→GCS), never across providers.
func CanCopyServerSideFromURL ¶ added in v0.1.25
CanCopyServerSideFromURL returns true when src can produce a public source URL and dst can copy from a URL server-side (e.g. Hugging Face → Azure).
func CanDownloadToFile ¶ added in v0.1.22
CanDownloadToFile reports whether src's backend supports an optimized download-to-local-file path.
func CanUploadFromFile ¶ added in v0.1.22
CanUploadFromFile reports whether dst's backend supports an optimized upload-from-local-file path.
func ChildPath ¶ added in v0.1.18
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 CopyServerSideFromURL ¶ added in v0.1.25
func CopyServerSideFromURL(ctx context.Context, src, dst string, concurrency int, onProgress CopyProgress) error
CopyServerSideFromURL resolves a public source URL from src and asks dst to copy from it server-side, without streaming the bytes through this process.
func DeletePrefix ¶ added in v0.1.18
DeletePrefix deletes all files under the prefix. Only Azure supports this natively.
func DownloadToFile ¶ added in v0.1.22
func DownloadToFile(ctx context.Context, src, localPath string, concurrency int, onProgress func(int64)) (int64, error)
DownloadToFile downloads the remote file at src into localPath using a backend-optimized transfer (parallel ranged GETs for Azure). onProgress, when non-nil, receives the cumulative number of bytes written. Returns the number of bytes downloaded.
func ExistsAsBlob ¶ added in v0.1.18
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 IsACR ¶ added in v0.1.26
IsACR returns true if the path targets an Azure Container Registry backend.
func IsDirLike ¶ added in v0.1.18
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
IsDirLikeFromPath checks if a path is directory-like without making any network calls. Uses path structure only.
func IsNonRetryableHTTPErr ¶ added in v0.1.18
IsNonRetryableHTTPErr reports whether err represents a failure that retrying cannot fix. That covers HTTP 401, 403 and 404 from any supported backend, plus, for ACR, a destination artifact that already exists, and any backend error exposing NotFound() == true.
A bare 409 or 412 is deliberately absent: HTTPStatusError does not say which request produced it, so treating those as final would also condemn a blob upload or an overwrite push that a retry would complete. The one conflict that is genuinely final — a create-only manifest write whose tag already holds something else — is reported as ErrArtifactExists instead.
A registry 404 is likewise not always final: an upload session the registry has forgotten answers BLOB_UPLOAD_UNKNOWN, and starting the upload again is exactly what recovers it, so the error code decides rather than the status.
func IsObjectStore ¶ added in v0.1.25
IsObjectStore returns true if the path targets a remote object-store backend with virtual-directory semantics and Stat-based existence checks (Azure Blob Storage, Amazon S3 or Google Cloud Storage).
func IsRemote ¶ added in v0.1.18
IsRemote returns true if the path targets a remote (non-local) backend.
func IsS3 ¶ added in v0.1.25
IsS3 returns true if the path targets an Amazon S3 (or S3-compatible) backend.
func ListFilesFlat ¶ added in v0.1.18
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
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
ListStream lists entries via a streaming callback. Falls back to List when the backend does not provide a streaming implementation.
func ParseShareInfo ¶ added in v0.1.18
ParseShareInfo returns shareable links for the path.
func PreAuthenticateAz ¶ added in v0.1.19
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 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. Identity credential lookup for untagged accounts still uses SRC_AZURE_* overrides and unprefixed AZURE_* defaults.
The function is safe to call repeatedly with a growing set of paths (as happens when task pairs are streamed): an account previously tagged with a role has its tag cleared once it is seen in both roles.
func ResolveDstPath ¶ added in v0.1.18
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
ScanConcurrency returns the scan concurrency stored in ctx, or 1 if unset.
func UploadArtifact ¶ added in v0.1.26
func UploadArtifact(ctx context.Context, dst string, files []ArtifactFile, concurrency int, overwrite bool, onProgress func(name string, uploaded int64)) error
UploadArtifact publishes files atomically as one backend artifact.
onProgress, when non-nil, receives a file's name and how many of its bytes have been uploaded so far. The value is cumulative per file and may restart at zero when a transfer is retried, so callers must track a high-water mark per name instead of treating each call as a delta.
func UploadConcurrency ¶ added in v0.1.19
UploadConcurrency returns the upload concurrency stored in ctx, or 1 if unset.
func UploadFromFile ¶ added in v0.1.22
func UploadFromFile(ctx context.Context, localPath, dst string, concurrency int, onProgress func(int64)) (int64, error)
UploadFromFile uploads the local file at localPath to dst using a backend-optimized transfer (parallel StageBlock for Azure). onProgress, when non-nil, receives the cumulative number of bytes staged. Returns the number of bytes uploaded.
func UploadReader ¶ added in v0.1.25
func UploadReader(ctx context.Context, dst string, r io.Reader, concurrency int, onProgress func(copied int64)) error
UploadReader writes r to dst using the backend's most reliable upload path, falling back to a plain streaming Write when the backend does not implement readerUploader. onProgress, when non-nil, receives cumulative bytes uploaded.
func WithScanConcurrency ¶ added in v0.1.18
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.
Types ¶
type ArtifactFile ¶ added in v0.1.26
type ArtifactFile struct {
Name string
Size int64
Open func() (io.ReadCloser, error)
}
ArtifactFile describes one file to publish in an artifact-oriented backend. Open must return a fresh reader for each call.
type CopyProgress ¶ added in v0.1.18
type CopyProgress = func(copied, total int64)
CopyProgress is the callback type for copy progress reporting.
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.
type ListResult ¶
ListResult wraps an Entry with an optional error from a listing operation.
type RecursiveSummary ¶ added in v0.1.26
RecursiveSummary contains aggregate metadata for a recursive file listing.
func SummarizeRecursive ¶ added in v0.1.26
func SummarizeRecursive(ctx context.Context, root string, onProgress func(count, size int64)) (RecursiveSummary, error)
SummarizeRecursive returns aggregate file count and size without retaining individual entries. Backends may optimize this operation independently.