2020-02-28 22:44:15 +08:00
|
|
|
package vfscommon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Options is options for creating the vfs
|
|
|
|
type Options struct {
|
|
|
|
NoSeek bool // don't allow seeking if set
|
|
|
|
NoChecksum bool // don't check checksums if set
|
|
|
|
ReadOnly bool // if set VFS is read only
|
|
|
|
NoModTime bool // don't read mod times for files
|
|
|
|
DirCacheTime time.Duration // how long to consider directory listing cache valid
|
|
|
|
PollInterval time.Duration
|
|
|
|
Umask int
|
|
|
|
UID uint32
|
|
|
|
GID uint32
|
|
|
|
DirPerms os.FileMode
|
|
|
|
FilePerms os.FileMode
|
|
|
|
ChunkSize fs.SizeSuffix // if > 0 read files in chunks
|
|
|
|
ChunkSizeLimit fs.SizeSuffix // if > ChunkSize double the chunk size after each chunk until reached
|
|
|
|
CacheMode CacheMode
|
|
|
|
CacheMaxAge time.Duration
|
|
|
|
CacheMaxSize fs.SizeSuffix
|
|
|
|
CachePollInterval time.Duration
|
|
|
|
CaseInsensitive bool
|
|
|
|
WriteWait time.Duration // time to wait for in-sequence write
|
|
|
|
ReadWait time.Duration // time to wait for in-sequence read
|
2020-04-17 18:18:58 +08:00
|
|
|
WriteBack time.Duration // time to wait before writing back dirty files
|
2020-08-05 16:57:03 +08:00
|
|
|
ReadAhead fs.SizeSuffix // bytes to read ahead in cache mode "full"
|
2021-02-18 04:36:13 +08:00
|
|
|
UsedIsSize bool // if true, use the `rclone size` algorithm for Used size
|
2022-03-22 00:15:12 +08:00
|
|
|
FastFingerprint bool // if set use fast fingerprints
|
2020-02-28 22:44:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultOpt is the default values uses for Opt
|
|
|
|
var DefaultOpt = Options{
|
|
|
|
NoModTime: false,
|
|
|
|
NoChecksum: false,
|
|
|
|
NoSeek: false,
|
|
|
|
DirCacheTime: 5 * 60 * time.Second,
|
|
|
|
PollInterval: time.Minute,
|
|
|
|
ReadOnly: false,
|
|
|
|
Umask: 0,
|
|
|
|
UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user
|
2020-05-20 18:39:20 +08:00
|
|
|
GID: ^uint32(0), // overridden for non windows in mount_unix.go
|
2020-02-28 22:44:15 +08:00
|
|
|
DirPerms: os.FileMode(0777),
|
|
|
|
FilePerms: os.FileMode(0666),
|
|
|
|
CacheMode: CacheModeOff,
|
|
|
|
CacheMaxAge: 3600 * time.Second,
|
|
|
|
CachePollInterval: 60 * time.Second,
|
2021-03-03 03:11:57 +08:00
|
|
|
ChunkSize: 128 * fs.Mebi,
|
2020-02-28 22:44:15 +08:00
|
|
|
ChunkSizeLimit: -1,
|
|
|
|
CacheMaxSize: -1,
|
|
|
|
CaseInsensitive: runtime.GOOS == "windows" || runtime.GOOS == "darwin", // default to true on Windows and Mac, false otherwise
|
|
|
|
WriteWait: 1000 * time.Millisecond,
|
2020-05-19 00:37:09 +08:00
|
|
|
ReadWait: 20 * time.Millisecond,
|
2020-04-17 18:18:58 +08:00
|
|
|
WriteBack: 5 * time.Second,
|
2021-03-03 03:11:57 +08:00
|
|
|
ReadAhead: 0 * fs.Mebi,
|
2021-02-18 04:36:13 +08:00
|
|
|
UsedIsSize: false,
|
2020-02-28 22:44:15 +08:00
|
|
|
}
|
2022-06-16 18:11:14 +08:00
|
|
|
|
|
|
|
// Init the options, making sure everything is withing range
|
|
|
|
func (opt *Options) Init() {
|
|
|
|
// Mask the permissions with the umask
|
|
|
|
opt.DirPerms &= ^os.FileMode(opt.Umask)
|
|
|
|
opt.FilePerms &= ^os.FileMode(opt.Umask)
|
|
|
|
|
|
|
|
// Make sure directories are returned as directories
|
|
|
|
opt.DirPerms |= os.ModeDir
|
|
|
|
|
|
|
|
}
|