mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 00:13:49 +01:00
vfs: add --vfs-disk-space-total-size option to manually set the total disk space
Now you can specify --vfs-disk-space-total-size to set the total disk space (default to -1) fixes #3270
This commit is contained in:
parent
2e54b56a01
commit
62bcc84f6f
@ -307,6 +307,13 @@ If the flag is not provided on the command line, then its default value depends
|
|||||||
on the operating system where rclone runs: "true" on Windows and macOS, "false"
|
on the operating system where rclone runs: "true" on Windows and macOS, "false"
|
||||||
otherwise. If the flag is provided without a value, then it is "true".
|
otherwise. If the flag is provided without a value, then it is "true".
|
||||||
|
|
||||||
|
### VFS Disk Options
|
||||||
|
|
||||||
|
This flag allows you to manually set the statistics about the filing system.
|
||||||
|
It can be useful when those statistics cannot be read correctly automatically.
|
||||||
|
|
||||||
|
--vfs-disk-space-total-size Manually set the total disk space size (example: 256G, default: -1)
|
||||||
|
|
||||||
### Alternate report of used bytes
|
### Alternate report of used bytes
|
||||||
|
|
||||||
Some backends, most notably S3, do not report the amount of bytes used.
|
Some backends, most notably S3, do not report the amount of bytes used.
|
||||||
|
@ -604,6 +604,7 @@ func (vfs *VFS) Statfs() (total, used, free int64) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if u := vfs.usage; u != nil {
|
if u := vfs.usage; u != nil {
|
||||||
if u.Total != nil {
|
if u.Total != nil {
|
||||||
total = *u.Total
|
total = *u.Total
|
||||||
@ -615,6 +616,11 @@ func (vfs *VFS) Statfs() (total, used, free int64) {
|
|||||||
used = *u.Used
|
used = *u.Used
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if int64(vfs.Opt.DiskSpaceTotalSize) >= 0 {
|
||||||
|
total = int64(vfs.Opt.DiskSpaceTotalSize)
|
||||||
|
}
|
||||||
|
|
||||||
total, used, free = fillInMissingSizes(total, used, free, unknownFreeBytes)
|
total, used, free = fillInMissingSizes(total, used, free, unknownFreeBytes)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,57 +10,59 @@ import (
|
|||||||
|
|
||||||
// Options is options for creating the vfs
|
// Options is options for creating the vfs
|
||||||
type Options struct {
|
type Options struct {
|
||||||
NoSeek bool // don't allow seeking if set
|
NoSeek bool // don't allow seeking if set
|
||||||
NoChecksum bool // don't check checksums if set
|
NoChecksum bool // don't check checksums if set
|
||||||
ReadOnly bool // if set VFS is read only
|
ReadOnly bool // if set VFS is read only
|
||||||
NoModTime bool // don't read mod times for files
|
NoModTime bool // don't read mod times for files
|
||||||
DirCacheTime time.Duration // how long to consider directory listing cache valid
|
DirCacheTime time.Duration // how long to consider directory listing cache valid
|
||||||
PollInterval time.Duration
|
PollInterval time.Duration
|
||||||
Umask int
|
Umask int
|
||||||
UID uint32
|
UID uint32
|
||||||
GID uint32
|
GID uint32
|
||||||
DirPerms os.FileMode
|
DirPerms os.FileMode
|
||||||
FilePerms os.FileMode
|
FilePerms os.FileMode
|
||||||
ChunkSize fs.SizeSuffix // if > 0 read files in chunks
|
ChunkSize fs.SizeSuffix // if > 0 read files in chunks
|
||||||
ChunkSizeLimit fs.SizeSuffix // if > ChunkSize double the chunk size after each chunk until reached
|
ChunkSizeLimit fs.SizeSuffix // if > ChunkSize double the chunk size after each chunk until reached
|
||||||
CacheMode CacheMode
|
CacheMode CacheMode
|
||||||
CacheMaxAge time.Duration
|
CacheMaxAge time.Duration
|
||||||
CacheMaxSize fs.SizeSuffix
|
CacheMaxSize fs.SizeSuffix
|
||||||
CachePollInterval time.Duration
|
CachePollInterval time.Duration
|
||||||
CaseInsensitive bool
|
CaseInsensitive bool
|
||||||
WriteWait time.Duration // time to wait for in-sequence write
|
WriteWait time.Duration // time to wait for in-sequence write
|
||||||
ReadWait time.Duration // time to wait for in-sequence read
|
ReadWait time.Duration // time to wait for in-sequence read
|
||||||
WriteBack time.Duration // time to wait before writing back dirty files
|
WriteBack time.Duration // time to wait before writing back dirty files
|
||||||
ReadAhead fs.SizeSuffix // bytes to read ahead in cache mode "full"
|
ReadAhead fs.SizeSuffix // bytes to read ahead in cache mode "full"
|
||||||
UsedIsSize bool // if true, use the `rclone size` algorithm for Used size
|
UsedIsSize bool // if true, use the `rclone size` algorithm for Used size
|
||||||
FastFingerprint bool // if set use fast fingerprints
|
FastFingerprint bool // if set use fast fingerprints
|
||||||
|
DiskSpaceTotalSize fs.SizeSuffix
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultOpt is the default values uses for Opt
|
// DefaultOpt is the default values uses for Opt
|
||||||
var DefaultOpt = Options{
|
var DefaultOpt = Options{
|
||||||
NoModTime: false,
|
NoModTime: false,
|
||||||
NoChecksum: false,
|
NoChecksum: false,
|
||||||
NoSeek: false,
|
NoSeek: false,
|
||||||
DirCacheTime: 5 * 60 * time.Second,
|
DirCacheTime: 5 * 60 * time.Second,
|
||||||
PollInterval: time.Minute,
|
PollInterval: time.Minute,
|
||||||
ReadOnly: false,
|
ReadOnly: false,
|
||||||
Umask: 0,
|
Umask: 0,
|
||||||
UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user
|
UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user
|
||||||
GID: ^uint32(0), // overridden for non windows in mount_unix.go
|
GID: ^uint32(0), // overridden for non windows in mount_unix.go
|
||||||
DirPerms: os.FileMode(0777),
|
DirPerms: os.FileMode(0777),
|
||||||
FilePerms: os.FileMode(0666),
|
FilePerms: os.FileMode(0666),
|
||||||
CacheMode: CacheModeOff,
|
CacheMode: CacheModeOff,
|
||||||
CacheMaxAge: 3600 * time.Second,
|
CacheMaxAge: 3600 * time.Second,
|
||||||
CachePollInterval: 60 * time.Second,
|
CachePollInterval: 60 * time.Second,
|
||||||
ChunkSize: 128 * fs.Mebi,
|
ChunkSize: 128 * fs.Mebi,
|
||||||
ChunkSizeLimit: -1,
|
ChunkSizeLimit: -1,
|
||||||
CacheMaxSize: -1,
|
CacheMaxSize: -1,
|
||||||
CaseInsensitive: runtime.GOOS == "windows" || runtime.GOOS == "darwin", // default to true on Windows and Mac, false otherwise
|
CaseInsensitive: runtime.GOOS == "windows" || runtime.GOOS == "darwin", // default to true on Windows and Mac, false otherwise
|
||||||
WriteWait: 1000 * time.Millisecond,
|
WriteWait: 1000 * time.Millisecond,
|
||||||
ReadWait: 20 * time.Millisecond,
|
ReadWait: 20 * time.Millisecond,
|
||||||
WriteBack: 5 * time.Second,
|
WriteBack: 5 * time.Second,
|
||||||
ReadAhead: 0 * fs.Mebi,
|
ReadAhead: 0 * fs.Mebi,
|
||||||
UsedIsSize: false,
|
UsedIsSize: false,
|
||||||
|
DiskSpaceTotalSize: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init the options, making sure everything is withing range
|
// Init the options, making sure everything is withing range
|
||||||
|
@ -39,5 +39,6 @@ func AddFlags(flagSet *pflag.FlagSet) {
|
|||||||
flags.FVarP(flagSet, &Opt.ReadAhead, "vfs-read-ahead", "", "Extra read ahead over --buffer-size when using cache-mode full")
|
flags.FVarP(flagSet, &Opt.ReadAhead, "vfs-read-ahead", "", "Extra read ahead over --buffer-size when using cache-mode full")
|
||||||
flags.BoolVarP(flagSet, &Opt.UsedIsSize, "vfs-used-is-size", "", Opt.UsedIsSize, "Use the `rclone size` algorithm for Used size")
|
flags.BoolVarP(flagSet, &Opt.UsedIsSize, "vfs-used-is-size", "", Opt.UsedIsSize, "Use the `rclone size` algorithm for Used size")
|
||||||
flags.BoolVarP(flagSet, &Opt.FastFingerprint, "vfs-fast-fingerprint", "", Opt.FastFingerprint, "Use fast (less accurate) fingerprints for change detection")
|
flags.BoolVarP(flagSet, &Opt.FastFingerprint, "vfs-fast-fingerprint", "", Opt.FastFingerprint, "Use fast (less accurate) fingerprints for change detection")
|
||||||
|
flags.FVarP(flagSet, &Opt.DiskSpaceTotalSize, "vfs-disk-space-total-size", "", "Specify the total space of disk")
|
||||||
platformFlags(flagSet)
|
platformFlags(flagSet)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user