options.go 3.0 KB

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