rclone/vfs/vfscommon/cachemode.go
Nick Craig-Wood 1cc22da87d vfs: re-implement CacheMode with fs.Enum
This almost 100% backwards compatible. The only difference being that
in the rc options/get output CacheMode will be output as strings
instead of integers. This is a lot more convenient for the user. They
still accept integer inputs though so the fallout from this should be
minimal.
2023-10-03 15:14:24 +01:00

33 lines
880 B
Go

// Package vfscommon provides utilities for VFS.
package vfscommon
import (
"github.com/rclone/rclone/fs"
)
type cacheModeChoices struct{}
func (cacheModeChoices) Choices() []string {
return []string{
CacheModeOff: "off",
CacheModeMinimal: "minimal",
CacheModeWrites: "writes",
CacheModeFull: "full",
}
}
// CacheMode controls the functionality of the cache
type CacheMode = fs.Enum[cacheModeChoices]
// CacheMode options
const (
CacheModeOff CacheMode = iota // cache nothing - return errors for writes which can't be satisfied
CacheModeMinimal // cache only the minimum, e.g. read/write opens
CacheModeWrites // cache all files opened with write intent
CacheModeFull // cache all files opened in any mode
)
// Type of the value
func (cacheModeChoices) Type() string {
return "CacheMode"
}