github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/vfs/vfscommon/options.go (about)

     1  package vfscommon
     2  
     3  import (
     4  	"os"
     5  	"runtime"
     6  	"time"
     7  
     8  	"github.com/rclone/rclone/fs"
     9  )
    10  
    11  // Options is options for creating the vfs
    12  type Options struct {
    13  	NoSeek             bool          // don't allow seeking if set
    14  	NoChecksum         bool          // don't check checksums if set
    15  	ReadOnly           bool          // if set VFS is read only
    16  	NoModTime          bool          // don't read mod times for files
    17  	DirCacheTime       time.Duration // how long to consider directory listing cache valid
    18  	Refresh            bool          // refreshes the directory listing recursively on start
    19  	PollInterval       time.Duration
    20  	Umask              int
    21  	UID                uint32
    22  	GID                uint32
    23  	DirPerms           os.FileMode
    24  	FilePerms          os.FileMode
    25  	ChunkSize          fs.SizeSuffix // if > 0 read files in chunks
    26  	ChunkSizeLimit     fs.SizeSuffix // if > ChunkSize double the chunk size after each chunk until reached
    27  	CacheMode          CacheMode
    28  	CacheMaxAge        time.Duration
    29  	CacheMaxSize       fs.SizeSuffix
    30  	CacheMinFreeSpace  fs.SizeSuffix
    31  	CachePollInterval  time.Duration
    32  	CaseInsensitive    bool
    33  	BlockNormDupes     bool
    34  	WriteWait          time.Duration // time to wait for in-sequence write
    35  	ReadWait           time.Duration // time to wait for in-sequence read
    36  	WriteBack          time.Duration // time to wait before writing back dirty files
    37  	ReadAhead          fs.SizeSuffix // bytes to read ahead in cache mode "full"
    38  	UsedIsSize         bool          // if true, use the `rclone size` algorithm for Used size
    39  	FastFingerprint    bool          // if set use fast fingerprints
    40  	DiskSpaceTotalSize fs.SizeSuffix
    41  }
    42  
    43  // DefaultOpt is the default values uses for Opt
    44  var DefaultOpt = Options{
    45  	NoModTime:          false,
    46  	NoChecksum:         false,
    47  	NoSeek:             false,
    48  	DirCacheTime:       5 * 60 * time.Second,
    49  	Refresh:            false,
    50  	PollInterval:       time.Minute,
    51  	ReadOnly:           false,
    52  	Umask:              0,
    53  	UID:                ^uint32(0), // these values instruct WinFSP-FUSE to use the current user
    54  	GID:                ^uint32(0), // overridden for non windows in mount_unix.go
    55  	DirPerms:           os.FileMode(0777),
    56  	FilePerms:          os.FileMode(0666),
    57  	CacheMode:          CacheModeOff,
    58  	CacheMaxAge:        3600 * time.Second,
    59  	CachePollInterval:  60 * time.Second,
    60  	ChunkSize:          128 * fs.Mebi,
    61  	ChunkSizeLimit:     -1,
    62  	CacheMaxSize:       -1,
    63  	CacheMinFreeSpace:  -1,
    64  	CaseInsensitive:    runtime.GOOS == "windows" || runtime.GOOS == "darwin", // default to true on Windows and Mac, false otherwise
    65  	WriteWait:          1000 * time.Millisecond,
    66  	ReadWait:           20 * time.Millisecond,
    67  	WriteBack:          5 * time.Second,
    68  	ReadAhead:          0 * fs.Mebi,
    69  	UsedIsSize:         false,
    70  	DiskSpaceTotalSize: -1,
    71  }
    72  
    73  // Init the options, making sure everything is within range
    74  func (opt *Options) Init() {
    75  	// Mask the permissions with the umask
    76  	opt.DirPerms &= ^os.FileMode(opt.Umask)
    77  	opt.FilePerms &= ^os.FileMode(opt.Umask)
    78  
    79  	// Make sure directories are returned as directories
    80  	opt.DirPerms |= os.ModeDir
    81  
    82  }