cached

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModeRemote indicates that the file is a remote file or directory.
	ModeRemote = fs.ModeSymlink | fs.ModeIrregular
)

Variables

View Source
var (
	// ErrOffline indicates that the remote filesystem is offline.
	ErrOffline = errors.New("remote filesystem is offline")
)

Functions

func DownloadFile

func DownloadFile(localFile string, file http.File) (err error)

DownloadFile downloads the file from the remote to the local cache file.

func IsOffline

func IsOffline(fs http.FileSystem) bool

IsOffline checks if the cached file system is in offline mode.

func IsRemote

func IsRemote(mode fs.FileMode) bool

IsRemote checks if the file mode indicates a remote file or directory.

func New

func New(local string, remote Remote, offline ...bool) http.FileSystem

New creates a new cached file system with the specified local cache directory and remote file system.

func NewEx

func NewEx(local string, remote Remote, offline ...bool) (_ http.FileSystem, err error)

NewEx creates a new cached file system with the specified local cache directory and remote file system.

Types

type Remote

type Remote interface {
	// Init initializes the remote file system with it local cache.
	Init(local string, offline bool) error

	// Lstat retrieves the cached FileInfo for the specified file or directory.
	Lstat(localFile string) (fs.FileInfo, error)

	// ReaddirAll reads all entries in the directory and returns their cached FileInfo.
	ReaddirAll(localDir string, dir *os.File, offline bool) (fis []fs.FileInfo, err error)

	// SyncLstat retrieves the FileInfo from the remote.
	SyncLstat(local string, name string) (fs.FileInfo, error)

	// SyncOpen retrieves the file from the remote.
	SyncOpen(local string, name string, fi fs.FileInfo) (http.File, error)
}

Remote is an interface for remote file system operations.

func RemoteOf

func RemoteOf(fs http.FileSystem) (r Remote, ok bool)

RemoteOf retrieves the remote file system from the cached file system.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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