2020-02-28 15:44:15 +01:00
|
|
|
package vfscommon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Options is options for creating the vfs
|
|
|
|
type Options struct {
|
2022-07-05 18:29:14 +02:00
|
|
|
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
|
2023-09-08 15:41:12 +02:00
|
|
|
Refresh bool // refreshes the directory listing recursively on start
|
2022-07-05 18:29:14 +02:00
|
|
|
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
|
2023-09-05 13:38:19 +02:00
|
|
|
CacheMinFreeSpace fs.SizeSuffix
|
2022-07-05 18:29:14 +02:00
|
|
|
CachePollInterval time.Duration
|
|
|
|
CaseInsensitive bool
|
vfs: fix unicode normalization on macOS - fixes #7072
Before this change, the VFS layer did not properly handle unicode normalization,
which caused problems particularly for users of macOS. While attempts were made
to handle it with various `-o modules=iconv` combinations, this was an imperfect
solution, as no one combination allowed both NFC and NFD content to
simultaneously be both visible and editable via Finder.
After this change, the VFS supports `--no-unicode-normalization` (default `false`)
via the existing `--vfs-case-insensitive` logic, which is extended to apply to both
case insensitivity and unicode normalization form.
This change also adds an additional flag, `--vfs-block-norm-dupes`, to address a
probably rare but potentially possible scenario where a directory contains
multiple duplicate filenames after applying case and unicode normalization
settings. In such a scenario, this flag (disabled by default) hides the
duplicates. This comes with a performance tradeoff, as rclone will have to scan
the entire directory for duplicates when listing a directory. For this reason,
it is recommended to leave this disabled if not needed. However, macOS users may
wish to consider using it, as otherwise, if a remote directory contains both NFC
and NFD versions of the same filename, an odd situation will occur: both
versions of the file will be visible in the mount, and both will appear to be
editable, however, editing either version will actually result in only the NFD
version getting edited under the hood. `--vfs-block-norm-dupes` prevents this
confusion by detecting this scenario, hiding the duplicates, and logging an
error, similar to how this is handled in `rclone sync`.
2024-02-05 08:58:11 +01:00
|
|
|
BlockNormDupes bool
|
2022-07-05 18:29:14 +02:00
|
|
|
WriteWait time.Duration // time to wait for in-sequence write
|
|
|
|
ReadWait time.Duration // time to wait for in-sequence read
|
|
|
|
WriteBack time.Duration // time to wait before writing back dirty files
|
|
|
|
ReadAhead fs.SizeSuffix // bytes to read ahead in cache mode "full"
|
|
|
|
UsedIsSize bool // if true, use the `rclone size` algorithm for Used size
|
|
|
|
FastFingerprint bool // if set use fast fingerprints
|
|
|
|
DiskSpaceTotalSize fs.SizeSuffix
|
2020-02-28 15:44:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultOpt is the default values uses for Opt
|
|
|
|
var DefaultOpt = Options{
|
2022-07-05 18:29:14 +02:00
|
|
|
NoModTime: false,
|
|
|
|
NoChecksum: false,
|
|
|
|
NoSeek: false,
|
|
|
|
DirCacheTime: 5 * 60 * time.Second,
|
2023-09-08 15:41:12 +02:00
|
|
|
Refresh: false,
|
2022-07-05 18:29:14 +02:00
|
|
|
PollInterval: time.Minute,
|
|
|
|
ReadOnly: false,
|
|
|
|
Umask: 0,
|
|
|
|
UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user
|
|
|
|
GID: ^uint32(0), // overridden for non windows in mount_unix.go
|
|
|
|
DirPerms: os.FileMode(0777),
|
|
|
|
FilePerms: os.FileMode(0666),
|
|
|
|
CacheMode: CacheModeOff,
|
|
|
|
CacheMaxAge: 3600 * time.Second,
|
|
|
|
CachePollInterval: 60 * time.Second,
|
|
|
|
ChunkSize: 128 * fs.Mebi,
|
|
|
|
ChunkSizeLimit: -1,
|
|
|
|
CacheMaxSize: -1,
|
2023-09-05 13:38:19 +02:00
|
|
|
CacheMinFreeSpace: -1,
|
2022-07-05 18:29:14 +02:00
|
|
|
CaseInsensitive: runtime.GOOS == "windows" || runtime.GOOS == "darwin", // default to true on Windows and Mac, false otherwise
|
|
|
|
WriteWait: 1000 * time.Millisecond,
|
|
|
|
ReadWait: 20 * time.Millisecond,
|
|
|
|
WriteBack: 5 * time.Second,
|
|
|
|
ReadAhead: 0 * fs.Mebi,
|
|
|
|
UsedIsSize: false,
|
|
|
|
DiskSpaceTotalSize: -1,
|
2020-02-28 15:44:15 +01:00
|
|
|
}
|
2022-06-16 12:11:14 +02:00
|
|
|
|
2023-03-25 08:10:16 +01:00
|
|
|
// Init the options, making sure everything is within range
|
2022-06-16 12:11:14 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
}
|