Documentation
¶
Index ¶
- Variables
- func GetHash(ctx context.Context, object fs.ObjectInfo) (string, error)
- func IsSameEntry(ctx context.Context, file model.File, object fs.ObjectInfo) (bool, string)
- type Backend
- type EmptyReadCloser
- type Entry
- type Handler
- type Lister
- type Name
- type Option
- type ProviderOptions
- type RCloneHandler
- func (h RCloneHandler) About(ctx context.Context) (*fs.Usage, error)
- func (h RCloneHandler) Check(ctx context.Context, path string) (fs.DirEntry, error)
- func (h RCloneHandler) List(ctx context.Context, path string) ([]fs.DirEntry, error)
- func (h RCloneHandler) Move(ctx context.Context, from fs.Object, to string) (fs.Object, error)
- func (h RCloneHandler) Name() string
- func (h RCloneHandler) Read(ctx context.Context, path string, offset int64, length int64) (io.ReadCloser, fs.Object, error)
- func (h RCloneHandler) Remove(ctx context.Context, obj fs.Object) error
- func (h RCloneHandler) Scan(ctx context.Context, path string, last string) <-chan Entry
- func (h RCloneHandler) Write(ctx context.Context, path string, in io.Reader) (fs.Object, error)
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
View Source
var BackendMap = make(map[string]Backend)
View Source
var Backends []Backend
View Source
var ErrBackendNotSupported = errors.New("This backend is not supported")
View Source
var ErrGetUsageNotSupported = errors.New("The backend does not support getting usage quota")
View Source
var ErrMoveNotSupported = errors.New("The backend does not support moving files")
View Source
var ErrStorageNotAvailable = errors.New("storage not available")
Functions ¶
func IsSameEntry ¶
IsSameEntry checks if a given model.File and a given fs.Object represent the same entry, based on their size, hash, and last modification time.
Parameters:
- ctx: Context that allows for asynchronous task cancellation.
- file: A model.File instance representing a file in the model.
- object: An fs.Object instance representing a file or object in the filesystem.
Returns:
- bool: A boolean indicating whether the given model.File and fs.Object are considered the same entry.
- string: A string providing details in case of a mismatch.
The function performs the following checks:
- Compares the sizes of 'file' and 'object'. If there is a mismatch, it returns false along with a formatted string that shows the mismatched sizes.
- Retrieves the last modified time of 'object'.
- Identifies a supported hash type for the storage backend of 'object' and computes its hash value.
- The hash computation is skipped if the storage backend is a local file system or does not support any hash types.
- If both 'file' and 'object' have non-empty hash values and these values do not match, it returns false along with a formatted string that shows the mismatched hash values.
- Compares the last modified times of 'file' and 'object' at the nanosecond precision. If there is a mismatch, it returns false along with a formatted string that shows the mismatched times.
- If all the checks pass (sizes, hashes, and last modified times match), the function returns true, indicating that 'file' and 'object' are considered to be the same entry.
Note: - In certain cases (e.g., failures during fetch), the last modified time might not be reliable. - For local file systems, hash computation is skipped to avoid inefficient operations.
Types ¶
type Backend ¶
type Backend struct {
// Name of this fs
Name string
// Description of this fs - defaults to Name
Description string
// Prefix for command line flags for this fs - defaults to Name if not set
Prefix string
// Different Config by Provider
ProviderOptions []ProviderOptions
}
type EmptyReadCloser ¶
type EmptyReadCloser struct{}
EmptyReadCloser is a ReadCloser that always returns EOF.
func (*EmptyReadCloser) Close ¶
func (e *EmptyReadCloser) Close() error
type Lister ¶
type Lister interface {
Name
// List lists the files at the given path.
List(ctx context.Context, path string) ([]fs.DirEntry, error)
// Scan scans the data source starting at the given path and returns a channel of entries.
// The `last` parameter is used to resume scanning from the last entry returned by a previous scan. It is exclusive.
// The returned entries must be sorted by path in ascending order.
Scan(ctx context.Context, path string, last string) <-chan Entry
// Check checks the size and last modified time of the file at the given path.
Check(ctx context.Context, path string) (fs.DirEntry, error)
}
type ProviderOptions ¶
func (ProviderOptions) ToCLICommand ¶
func (p ProviderOptions) ToCLICommand(short string, long string, description string) *cli.Command
type RCloneHandler ¶
type RCloneHandler struct {
// contains filtered or unexported fields
}
func NewRCloneHandler ¶
func (RCloneHandler) Name ¶
func (h RCloneHandler) Name() string
type Reader ¶
type Reader interface {
Name
// Read reads data from the source storage file starting at the given path and offset, and returns a ReadCloser.
// The `length` parameter specifies the number of bytes to read.
// This method is most likely used for retrieving a single block of data.
Read(ctx context.Context, path string, offset int64, length int64) (io.ReadCloser, fs.Object, error)
}
type Writer ¶
type Writer interface {
Name
// Write writes data to the output storage file.
Write(ctx context.Context, path string, in io.Reader) (fs.Object, error)
// Move moves the given object to the given path.
Move(ctx context.Context, from fs.Object, to string) (fs.Object, error)
// Remove removes the given object.
Remove(ctx context.Context, obj fs.Object) error
}
Click to show internal directories.
Click to hide internal directories.